Final refactor

This commit is contained in:
BarsTiger
2022-02-06 16:57:10 +02:00
parent be4c49ecf3
commit 46b5329318
7 changed files with 15 additions and 14 deletions

View File

@@ -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_

View File

@@ -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:

View File

@@ -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")

View File

@@ -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:

View File

@@ -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()

View File

@@ -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)

View File

@@ -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')