From 237aa7ff31253d4a6a29dfb6234de89843e711fa Mon Sep 17 00:00:00 2001 From: jonnybravo Date: Tue, 11 Apr 2023 17:21:50 +0200 Subject: [PATCH] commit message from python script --- .../kde_autostart_sshagent_folder_create.py | 2 +- check_and_add_pull_git/main.py | 49 +++++++++++++++++++ create_mygit_default_conf/main.py | 0 create_selfsign/selfsing.py | 0 my_backups/backup_main.py | 0 read_all_user/main.py | 0 ssh_with_sub/main.py | 0 ssh_with_sub/test.csv | 0 test_skripte/mem_test.py | 7 +++ 9 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 check_and_add_pull_git/main.py mode change 100644 => 100755 create_mygit_default_conf/main.py mode change 100644 => 100755 create_selfsign/selfsing.py mode change 100644 => 100755 my_backups/backup_main.py mode change 100644 => 100755 read_all_user/main.py mode change 100644 => 100755 ssh_with_sub/main.py mode change 100644 => 100755 ssh_with_sub/test.csv create mode 100644 test_skripte/mem_test.py diff --git a/add_start_ssh_agent_on_kde/kde_autostart_sshagent_folder_create.py b/add_start_ssh_agent_on_kde/kde_autostart_sshagent_folder_create.py index 6a1a98a..868b2f7 100755 --- a/add_start_ssh_agent_on_kde/kde_autostart_sshagent_folder_create.py +++ b/add_start_ssh_agent_on_kde/kde_autostart_sshagent_folder_create.py @@ -50,7 +50,7 @@ def create_scripts_startup(script_folder = str): try: script_file = script_folder + "/ssh-agent-shartup.sh" with open(file=script_file, mode="w" ) as script: - print("""#!/bin/sh\n[ -z "$SSH_AGENT_PID" ] || eval "$(ssh-agent -s)"\nSSH_ASKPASS=/usr/bin/ksshaskpass\nexport SSH_ASKPASS""", file=script) + print("""#!/bin/sh\n[ -n "$SSH_AGENT_PID" ] || eval "$(ssh-agent -s)"\nSSH_ASKPASS=/usr/bin/ksshaskpass\nexport SSH_ASKPASS""", file=script) os.chmod(path=script_file, mode=stat.S_IRWXU) except: raise PermissionError("Keine Rechte die Datei " + script_file + " zu erstellen") diff --git a/check_and_add_pull_git/main.py b/check_and_add_pull_git/main.py new file mode 100644 index 0000000..22866f2 --- /dev/null +++ b/check_and_add_pull_git/main.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 + +import os, git + +class my_git(): + def __init__(self, check_folder = str) -> None: + self.check_folders = check_folder + def check_folder(self): + li_all_fo_git = [] + for root, dirs, files in os.walk(self.check_folders, topdown=False): + for name in dirs: + FullPATH = str(os.path.join(root, name)) + if name == ".git": + li_all_fo_git.append(root) + return li_all_fo_git + + def git_pull(self, git_folder): + repo = git.Repo(git_folder) + for remote in repo.remotes: + remote_name = repo.remote(name=remote.name) + remote_name.pull() + + def git_push(self, git_folder): + repo = git.Repo(git_folder) + if not repo.is_dirty(untracked_files=True): + print('No Changes detected.') + else: + print("what") + for remote in repo.remotes: + print(remote.name, remote.url) + repo.git.add('--all') + repo.git.commit('-m', 'commit message from python script') + remote_name = repo.remote(name=remote.name) + remote_name.push() + + def git_main(self): + list_git_folder = my_git.check_folder(self) + for git_folder_s in list_git_folder: + print(git_folder_s) + #my_git.git_pull(self, git_folder=git_folder_s) + my_git.git_push(self, git_folder=git_folder_s) + + + + + +if __name__ == "__main__": + check_my_git = my_git(check_folder= os.sep + "home" + os.sep + os.environ["USER"] + os.sep + "Projekte") + check_my_git.git_main() diff --git a/create_mygit_default_conf/main.py b/create_mygit_default_conf/main.py old mode 100644 new mode 100755 diff --git a/create_selfsign/selfsing.py b/create_selfsign/selfsing.py old mode 100644 new mode 100755 diff --git a/my_backups/backup_main.py b/my_backups/backup_main.py old mode 100644 new mode 100755 diff --git a/read_all_user/main.py b/read_all_user/main.py old mode 100644 new mode 100755 diff --git a/ssh_with_sub/main.py b/ssh_with_sub/main.py old mode 100644 new mode 100755 diff --git a/ssh_with_sub/test.csv b/ssh_with_sub/test.csv old mode 100644 new mode 100755 diff --git a/test_skripte/mem_test.py b/test_skripte/mem_test.py new file mode 100644 index 0000000..b769760 --- /dev/null +++ b/test_skripte/mem_test.py @@ -0,0 +1,7 @@ +#! /usr/bin/env python3 + +import os, sys + + +if not os.path.exists(os.sep + "home" + os.sep + os.environ["USER"]) is True: + print("yes") \ No newline at end of file