Final refactor
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# [🎠horsy](https://horsy.ml/) [](https://horsy.ml/)
|
# [🎠horsy](https://horsy.ml/) [](https://horsy.ml/)
|
||||||
|
|
||||||
## _The Best Open Source Package Manager_
|
## _The Best Open Source Package Manager_
|
||||||
|
|
||||||
|
|||||||
4
horsy.py
4
horsy.py
@@ -46,11 +46,11 @@ if not os.path.isfile(horsy_vars.horsypath + 'config.cfg'):
|
|||||||
try:
|
try:
|
||||||
with open(horsy_vars.horsypath + 'apps/version', 'r') as f:
|
with open(horsy_vars.horsypath + 'apps/version', 'r') as f:
|
||||||
version = int(f.read())
|
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!')
|
print('New version available!')
|
||||||
input('Press enter to update...')
|
input('Press enter to update...')
|
||||||
with open(os.path.join(horsy_vars.horsypath) + '/horsy_updater.exe', 'wb') as f:
|
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')
|
os.system('horsy_updater.exe horsy')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except:
|
except:
|
||||||
|
|||||||
@@ -185,12 +185,12 @@ def install():
|
|||||||
threads = list()
|
threads = list()
|
||||||
ui.logs_box.append("Adding task to download horsy")
|
ui.logs_box.append("Adding task to download horsy")
|
||||||
threads.append(threading.Thread(target=urllib.request.urlretrieve,
|
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'), ))
|
os.path.join(path_to_install) + '/horsy.exe'), ))
|
||||||
if ui.install_gui_check.isChecked():
|
if ui.install_gui_check.isChecked():
|
||||||
ui.logs_box.append("Adding task to download horsygui")
|
ui.logs_box.append("Adding task to download horsygui")
|
||||||
threads.append(threading.Thread(target=urllib.request.urlretrieve,
|
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'), ))
|
os.path.join(path_to_install) + '/horsygui.exe'), ))
|
||||||
try:
|
try:
|
||||||
ui.logs_box.append("Starting tasks")
|
ui.logs_box.append("Starting tasks")
|
||||||
@@ -204,7 +204,7 @@ def install():
|
|||||||
add_var(path_to_install)
|
add_var(path_to_install)
|
||||||
add_to_path(os.path.join(path_to_install))
|
add_to_path(os.path.join(path_to_install))
|
||||||
ui.logs_box.append("Downloading version file")
|
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')
|
os.path.join(path_to_install) + '/apps/version')
|
||||||
ui.logs_box.append("Version specified")
|
ui.logs_box.append("Version specified")
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ if not os.path.exists(path_to_install + "\\apps"):
|
|||||||
os.makedirs(path_to_install + "\\apps")
|
os.makedirs(path_to_install + "\\apps")
|
||||||
threads = list()
|
threads = list()
|
||||||
threads.append(threading.Thread(target=urllib.request.urlretrieve,
|
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'), ))
|
os.path.join(path_to_install) + '/horsy.exe'), ))
|
||||||
if os.path.exists(path_to_install + '/horsygui.exe'):
|
if os.path.exists(path_to_install + '/horsygui.exe'):
|
||||||
threads.append(threading.Thread(target=urllib.request.urlretrieve,
|
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'), ))
|
os.path.join(path_to_install) + '/horsygui.exe'), ))
|
||||||
try:
|
try:
|
||||||
for thread in threads:
|
for thread in threads:
|
||||||
@@ -31,7 +31,7 @@ except:
|
|||||||
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
|
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
|
||||||
sys.exit()
|
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')
|
os.path.join(path_to_install) + '/apps/version')
|
||||||
|
|
||||||
for thread in threads:
|
for thread in threads:
|
||||||
|
|||||||
@@ -227,18 +227,18 @@ if __name__ == "__main__":
|
|||||||
except:
|
except:
|
||||||
gui.popup('Error', 'Horsy may be not installed correctly. Please reinstall it.')
|
gui.popup('Error', 'Horsy may be not installed correctly. Please reinstall it.')
|
||||||
version = int(f.read())
|
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.'
|
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.')
|
'\nPress OK and updater will download the latest version.')
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(horsy_vars.horsypath) + '/horsy_updater.exe', 'wb') as f:
|
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:
|
except:
|
||||||
gui.popup('Error', 'Could not download updater. \nMaybe installation folder is not writable '
|
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'
|
'(only for admins).\n Please reinstall horsy or update it manually. \n'
|
||||||
'Click OK, download file that will open browser and launch it.\n'
|
'Click OK, download file that will open browser and launch it.\n'
|
||||||
'Afterwards, delete updater file and launch horsy again.')
|
'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()
|
UiMainWindow.close()
|
||||||
os.system('horsy_updater.exe horsygui')
|
os.system('horsy_updater.exe horsygui')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ def install(package):
|
|||||||
r = requests.get(f"{horsy_vars.protocol}{horsy_vars.server_url}/packages/json/{package}").text
|
r = requests.get(f"{horsy_vars.protocol}{horsy_vars.server_url}/packages/json/{package}").text
|
||||||
if r == "":
|
if r == "":
|
||||||
run_threaded(popup("Installation", f"Package {package} not found"))
|
run_threaded(popup("Installation", f"Package {package} not found"))
|
||||||
|
print(r)
|
||||||
return f"Package {package} not found"
|
return f"Package {package} not found"
|
||||||
try:
|
try:
|
||||||
r = json.loads(r)
|
r = json.loads(r)
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import json
|
|||||||
from rich import print
|
from rich import print
|
||||||
|
|
||||||
client = SearchClient.create(
|
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/horsy-ml/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()['API_KEY'])
|
||||||
index = client.init_index('packages')
|
index = client.init_index('packages')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user