Updating horsy now works
This commit is contained in:
20
horsy.py
20
horsy.py
@@ -1,5 +1,6 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import requests
|
import requests
|
||||||
import modules.tui as tui
|
import modules.tui as tui
|
||||||
@@ -35,17 +36,22 @@ 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/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/horsy-ml/horsy/raw/master/bin/horsy_updater.exe').content)
|
|
||||||
os.system('horsy_updater.exe horsy')
|
|
||||||
sys.exit(0)
|
|
||||||
except:
|
except:
|
||||||
print('Horsy may be not installed correctly. Please reinstall it or stop other horsy instances. '
|
print('Horsy may be not installed correctly. Please reinstall it or stop other horsy instances. '
|
||||||
'If you installed it just now, please restart PC.')
|
'If you installed it just now, please restart PC.')
|
||||||
|
|
||||||
|
if int(requests.get('https://github.com/horsy-ml/horsy/raw/master/web_vars/version').text) > version:
|
||||||
|
print('New version available!')
|
||||||
|
print('If you see this message again, or horsy doesn\'t launch itself for long time, please type '
|
||||||
|
'horsy_updater in your terminal to update it manually.')
|
||||||
|
input('Press enter to update...')
|
||||||
|
print('Updating...')
|
||||||
|
print('Please wait, if process seems closed, its OK, just wait a bit.')
|
||||||
|
with open(os.path.join(horsy_vars.horsypath) + '/horsy_updater.exe', 'wb') as f:
|
||||||
|
f.write(requests.get('https://github.com/horsy-ml/horsy/raw/master/bin/horsy_updater.exe').content)
|
||||||
|
subprocess.Popen('horsy_updater.exe horsy', shell=True, close_fds=True)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
isNoArgs = False
|
isNoArgs = False
|
||||||
|
|
||||||
|
|||||||
@@ -37,4 +37,7 @@ urllib.request.urlretrieve("https://github.com/horsy-ml/horsy/raw/master/web_var
|
|||||||
for thread in threads:
|
for thread in threads:
|
||||||
thread.join()
|
thread.join()
|
||||||
|
|
||||||
os.system(option)
|
try:
|
||||||
|
os.system(option)
|
||||||
|
except:
|
||||||
|
input("horsy updated manually. You can launch it now. Press enter to exit.")
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from PyQt5 import QtWidgets
|
|||||||
import ctypes
|
import ctypes
|
||||||
import modules.gui as gui
|
import modules.gui as gui
|
||||||
import requests
|
import requests
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
# Hide console window (does not work on custom terminals like Windows Terminal)
|
# Hide console window (does not work on custom terminals like Windows Terminal)
|
||||||
@@ -237,7 +238,9 @@ if __name__ == "__main__":
|
|||||||
version = int(f.read())
|
version = int(f.read())
|
||||||
if int(requests.get('https://github.com/horsy-ml/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.\n'
|
||||||
|
'If you see this message again, or horsy doesn\'t launch \n'
|
||||||
|
'itself for long time, please type horsy_updater in your terminal.')
|
||||||
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/horsy-ml/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)
|
||||||
@@ -248,7 +251,7 @@ if __name__ == "__main__":
|
|||||||
'Afterwards, delete updater file and launch horsy again.')
|
'Afterwards, delete updater file and launch horsy again.')
|
||||||
webbrowser.open('https://github.com/horsy-ml/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')
|
subprocess.Popen('horsy_updater.exe horsygui', shell=True, close_fds=True)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
get_users_apps()
|
get_users_apps()
|
||||||
|
|||||||
Reference in New Issue
Block a user