diff --git a/src/download_main.py b/src/download_main.py index 49d0ac1..04c0515 100644 --- a/src/download_main.py +++ b/src/download_main.py @@ -5,26 +5,24 @@ import json import json_main import download_gitlab import download_github +import install_main -download_foler = "." -install_folder = "." - -def sanity_check(): +def sanity_check(download_folder,install_folder): # Ensure that the directory structure exists - if not os.path.exists(download_foler): - os.makedirs(download_foler) + if not os.path.exists(download_folder): + os.makedirs(download_folder) # Ensure that the directory structure exists, once again if not os.path.exists(install_folder): os.makedirs(install_folder) # Check if config.json exists and create it with default values if not - if not os.path.isfile(download_foler+"config.json"): + if not os.path.isfile(download_folder+"config.json"): default_data = { "first_run": "false", "packages": [] } - with open(download_foler+"config.json", "w") as json_file: + with open(download_folder+"config.json", "w") as json_file: json.dump(default_data, json_file, indent=4) # Placeholder functions for SourceForge and Gitea @@ -37,12 +35,14 @@ def download_from_gitea(api_url, project_id, token, destination, progress_bar, v print("Gita not supported, yet") # Function to install all packages -def install_all_packages(progress_bar, progress_label,download_location,install_location): - download_foler=download_location - install_folder=install_location - sanity_check() +def download_all_packages(progress_bar, progress_label, download_location, install_location): + download_folder = download_location + "/" + install_folder = install_location + "/" + print(f"install location {install_folder}") + print(f"download location {download_folder}") + sanity_check(download_folder,install_folder) try: - with open(download_foler+"config.json", 'r') as file: + with open(download_folder+"config.json", 'r') as file: data = json.load(file) packages = data.get("packages", []) total_packages = len(packages) @@ -59,10 +59,10 @@ def install_all_packages(progress_bar, progress_label,download_location,install_ progress_bar.set_fraction(progress_value) if source_type == "github": - download_github.download_from_github(source_info["github_url"], app_name, tqdm, version) + download_github.download_from_github(source_info["github_url"], download_folder+app_name, tqdm, version) #(api_url, project_id, token, destination, progress_bar) elif source_type == "gitlab": download_gitlab.download_and_update(source_info["gitlab_api_url"], source_info["project_id"], - source_info["private_token"], app_name, tqdm, version) + source_info["private_token"], download_folder+app_name, tqdm, version) # Add other source types as needed else: progress_label.set_text(f"Unsupported source type for {app_name}: {source_type}") @@ -70,6 +70,7 @@ def install_all_packages(progress_bar, progress_label,download_location,install_ except Exception as e: progress_label.set_text(f"Error processing {app_name}: {e}") print(f"Error processing {app_name}: {e}") + install_main.install_all_packages() except FileNotFoundError: progress_label.set_text(f"Config file not found.") print("Config file not found.") diff --git a/src/gui_main.py b/src/gui_main.py index 04d42a0..da63b05 100644 --- a/src/gui_main.py +++ b/src/gui_main.py @@ -6,7 +6,7 @@ import threading import download_main number_of_tabs = 4 -download_foler = "." +download_folder = "." class InstallerGUI: def __init__(self): @@ -43,11 +43,12 @@ class UpdaterGUI(Gtk.Box): def on_realize(self, widget): # Run the install_all_packages function in a separate thread when the widget becomes visible - threading.Thread(target=self.run_installation).start() + print(download_folder) + threading.Thread(target=self.run_installation(download_folder)).start() - def run_installation(self): + def run_installation(self,download_folder): # Pass the progress bar and label to the install_all_packages function - download_main.install_all_packages(self.progress_bar, self.progress_label, download_foler,"./data/") + download_main.download_all_packages(self.progress_bar, self.progress_label, download_folder,"./data/") # Glib.idle_add() ? @@ -203,7 +204,7 @@ class MainWindow(Gtk.ApplicationWindow): # Make the MainWindow class callable as a function def run_installer(download_foler_tmp): - download_foler = download_foler_tmp + download_folder = download_foler_tmp app = Gtk.Application(application_id="com.spitfire.launcher", flags=Gio.ApplicationFlags.FLAGS_NONE) app.connect("activate", lambda app: MainWindow(application=app)) diff --git a/src/install_main.py b/src/install_main.py new file mode 100644 index 0000000..62e8a24 --- /dev/null +++ b/src/install_main.py @@ -0,0 +1,4 @@ + + +def install_all_packages(): + print("installing!") \ No newline at end of file diff --git a/test.json b/test.json new file mode 100644 index 0000000..fec8eee --- /dev/null +++ b/test.json @@ -0,0 +1,1017 @@ +{ + "first_run": "false", + "packages": [ + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + }, + { + "my_app_github": { + "version": "1.0", + "source": { + "source_type": "github", + "github_url": "https://api.github.com/repos/emoacht/Monitorian" + }, + "state": "not installed", + "type": "addon" + } + }, + { + "my_app_gitlab": { + "version": "1.0", + "source": { + "source_type": "gitlab", + "gitlab_api_url": "https://gitlab.com/api/v4", + "project_id": 5774889, + "private_token": "" + }, + "state": "not installed", + "type": "skin" + } + }, + { + "my_app_gitea": { + "version": "1.0", + "source": { + "source_type": "gitea" + }, + "state": "not installed", + "type": "config" + } + }, + { + "my_app_sourceforge": { + "version": "1.0", + "source": { + "source_type": "sourceforge" + }, + "state": "not installed", + "type": "panel" + } + } + ] +} \ No newline at end of file