From 6d0b14b1872353a689277036ee9c116314d2db97 Mon Sep 17 00:00:00 2001 From: "N0\\A" Date: Thu, 23 Oct 2025 19:31:41 +0200 Subject: [PATCH] Updater --- core/updater.py | 27 +++++++++++++++++++++++++++ main.py | 6 ++++++ 2 files changed, 33 insertions(+) create mode 100644 core/updater.py diff --git a/core/updater.py b/core/updater.py new file mode 100644 index 0000000..01ae175 --- /dev/null +++ b/core/updater.py @@ -0,0 +1,27 @@ +from git import Repo +from pathlib import Path + +REPO_URL = "https://github.com/n0va-bot/CLARA" +REPO_DIR = Path(__file__).parent + +def update_repository(): + try: + repo = Repo(REPO_DIR) + current_branch = repo.active_branch + + print(f"Fetching latest changes from {current_branch}...") + origin = repo.remotes.origin + origin.fetch() + + print(f"Pulling changes for branch {current_branch}...") + origin.pull() + + print("Repository updated successfully.") + return True + except Exception as e: + print(f"Error updating repository: {e}") + return False + +if __name__ == "__main__": + REPO_DIR = Path(__file__).parent / ".." + update_repository() \ No newline at end of file diff --git a/main.py b/main.py index 4d543c4..10431d4 100644 --- a/main.py +++ b/main.py @@ -7,6 +7,7 @@ from core.file_search import find from core.web_search import MullvadLetaWrapper from core.discord_presence import presence from core.app_launcher import list_apps, launch, App +from core.updater import update_repository ASSET = Path(__file__).parent / "assets" / "2ktan.png" @@ -351,6 +352,7 @@ class MainWindow(QtWidgets.QMainWindow): right_menu.addAction("Search Files", self.start_file_search) right_menu.addAction("Search Web", self.start_web_search) right_menu.addSeparator() + right_menu.addAction("Check for updates", self.update_git) if restart: right_menu.addAction("Restart", self.restart_application) right_menu.addAction("Hide/Show", self.toggle_visible) @@ -446,6 +448,10 @@ class MainWindow(QtWidgets.QMainWindow): finally: QtWidgets.QApplication.restoreOverrideCursor() + def update_git(self): + update_repository() + self.restart_application() + def restart_application(self): subprocess.Popen([sys.executable] + sys.argv) QtWidgets.QApplication.quit()