From 46b5329318584962e38306c6ed5dcfd9b1ac7105 Mon Sep 17 00:00:00 2001 From: BarsTiger Date: Sun, 6 Feb 2022 16:57:10 +0200 Subject: [PATCH] Final refactor --- README.md | 2 +- horsy.py | 4 ++-- horsy_installer.py | 6 +++--- horsy_updater.py | 6 +++--- horsygui.py | 6 +++--- modules/gui_manager.py | 1 + modules/search.py | 4 ++-- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index b88eec2..1320480 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# [🎠horsy](https://horsy.ml/) [![logo](https://raw.githubusercontent.com/BarsTiger/horsy/master/img/horsy32x32.png)](https://horsy.ml/) +# [🎠horsy](https://horsy.ml/) [![logo](https://raw.githubusercontent.com/horsy-ml/horsy/master/img/horsy32x32.png)](https://horsy.ml/) ## _The Best Open Source Package Manager_ diff --git a/horsy.py b/horsy.py index 36f7caa..84220bd 100644 --- a/horsy.py +++ b/horsy.py @@ -46,11 +46,11 @@ if not os.path.isfile(horsy_vars.horsypath + 'config.cfg'): try: with open(horsy_vars.horsypath + 'apps/version', 'r') as f: version = int(f.read()) - if int(requests.get('https://github.com/BarsTiger/horsy/raw/master/web_vars/version').text) > version: + if int(requests.get('https://github.com/horsy-ml/horsy/raw/master/web_vars/version').text) > version: print('New version available!') input('Press enter to update...') with open(os.path.join(horsy_vars.horsypath) + '/horsy_updater.exe', 'wb') as f: - f.write(requests.get('https://github.com/BarsTiger/horsy/raw/master/bin/horsy_updater.exe').content) + f.write(requests.get('https://github.com/horsy-ml/horsy/raw/master/bin/horsy_updater.exe').content) os.system('horsy_updater.exe horsy') sys.exit(0) except: diff --git a/horsy_installer.py b/horsy_installer.py index 3877162..0385bcf 100644 --- a/horsy_installer.py +++ b/horsy_installer.py @@ -185,12 +185,12 @@ def install(): threads = list() ui.logs_box.append("Adding task to download horsy") threads.append(threading.Thread(target=urllib.request.urlretrieve, - args=("https://github.com/BarsTiger/horsy/raw/master/bin/horsy.exe", + args=("https://github.com/horsy-ml/horsy/raw/master/bin/horsy.exe", os.path.join(path_to_install) + '/horsy.exe'), )) if ui.install_gui_check.isChecked(): ui.logs_box.append("Adding task to download horsygui") threads.append(threading.Thread(target=urllib.request.urlretrieve, - args=("https://github.com/BarsTiger/horsy/raw/master/bin/horsygui.exe", + args=("https://github.com/horsy-ml/horsy/raw/master/bin/horsygui.exe", os.path.join(path_to_install) + '/horsygui.exe'), )) try: ui.logs_box.append("Starting tasks") @@ -204,7 +204,7 @@ def install(): add_var(path_to_install) add_to_path(os.path.join(path_to_install)) ui.logs_box.append("Downloading version file") - urllib.request.urlretrieve("https://github.com/BarsTiger/horsy/raw/master/web_vars/version", + urllib.request.urlretrieve("https://github.com/horsy-ml/horsy/raw/master/web_vars/version", os.path.join(path_to_install) + '/apps/version') ui.logs_box.append("Version specified") diff --git a/horsy_updater.py b/horsy_updater.py index b648a50..da1878b 100644 --- a/horsy_updater.py +++ b/horsy_updater.py @@ -18,11 +18,11 @@ if not os.path.exists(path_to_install + "\\apps"): os.makedirs(path_to_install + "\\apps") threads = list() threads.append(threading.Thread(target=urllib.request.urlretrieve, - args=("https://github.com/BarsTiger/horsy/raw/master/bin/horsy.exe", + args=("https://github.com/horsy-ml/horsy/raw/master/bin/horsy.exe", os.path.join(path_to_install) + '/horsy.exe'), )) if os.path.exists(path_to_install + '/horsygui.exe'): threads.append(threading.Thread(target=urllib.request.urlretrieve, - args=("https://github.com/BarsTiger/horsy/raw/master/bin/horsygui.exe", + args=("https://github.com/horsy-ml/horsy/raw/master/bin/horsygui.exe", os.path.join(path_to_install) + '/horsygui.exe'), )) try: for thread in threads: @@ -31,7 +31,7 @@ except: ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1) sys.exit() -urllib.request.urlretrieve("https://github.com/BarsTiger/horsy/raw/master/web_vars/version", +urllib.request.urlretrieve("https://github.com/horsy-ml/horsy/raw/master/web_vars/version", os.path.join(path_to_install) + '/apps/version') for thread in threads: diff --git a/horsygui.py b/horsygui.py index bbe2e2b..9623e6e 100644 --- a/horsygui.py +++ b/horsygui.py @@ -227,18 +227,18 @@ if __name__ == "__main__": except: gui.popup('Error', 'Horsy may be not installed correctly. Please reinstall it.') version = int(f.read()) - if int(requests.get('https://github.com/BarsTiger/horsy/raw/master/web_vars/version').text) > version: + if int(requests.get('https://github.com/horsy-ml/horsy/raw/master/web_vars/version').text) > version: gui.popup('Update', 'New version available! \nWe appreciate your safety, so you need to update horsy.' '\nPress OK and updater will download the latest version.') try: with open(os.path.join(horsy_vars.horsypath) + '/horsy_updater.exe', 'wb') as f: - f.write(requests.get('https://github.com/BarsTiger/horsy/raw/master/bin/horsy_updater.exe').content) + f.write(requests.get('https://github.com/horsy-ml/horsy/raw/master/bin/horsy_updater.exe').content) except: gui.popup('Error', 'Could not download updater. \nMaybe installation folder is not writable ' '(only for admins).\n Please reinstall horsy or update it manually. \n' 'Click OK, download file that will open browser and launch it.\n' 'Afterwards, delete updater file and launch horsy again.') - webbrowser.open('https://github.com/BarsTiger/horsy/raw/master/bin/horsy_updater.exe') + webbrowser.open('https://github.com/horsy-ml/horsy/raw/master/bin/horsy_updater.exe') UiMainWindow.close() os.system('horsy_updater.exe horsygui') sys.exit() diff --git a/modules/gui_manager.py b/modules/gui_manager.py index fdc44c6..06e4e56 100644 --- a/modules/gui_manager.py +++ b/modules/gui_manager.py @@ -17,6 +17,7 @@ def install(package): r = requests.get(f"{horsy_vars.protocol}{horsy_vars.server_url}/packages/json/{package}").text if r == "": run_threaded(popup("Installation", f"Package {package} not found")) + print(r) return f"Package {package} not found" try: r = json.loads(r) diff --git a/modules/search.py b/modules/search.py index c949064..4a0aa5a 100644 --- a/modules/search.py +++ b/modules/search.py @@ -7,8 +7,8 @@ import json from rich import print client = SearchClient.create( - requests.get('https://raw.githubusercontent.com/BarsTiger/horsy/master/web_vars/search_app').json()['APP_ID'], - requests.get('https://raw.githubusercontent.com/BarsTiger/horsy/master/web_vars/search_app').json()['API_KEY']) + requests.get('https://raw.githubusercontent.com/horsy-ml/horsy/master/web_vars/search_app').json()['APP_ID'], + requests.get('https://raw.githubusercontent.com/horsy-ml/horsy/master/web_vars/search_app').json()['API_KEY']) index = client.init_index('packages')