diff --git a/horsy.py b/horsy.py index 24d235b..c0ac518 100644 --- a/horsy.py +++ b/horsy.py @@ -48,6 +48,11 @@ try: version = int(f.read()) if int(requests.get('https://github.com/BarsTiger/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) + os.system('horsy_updater.exe horsy') + sys.exit(0) except: print('Horsy may be not installed correctly. Please reinstall it.') diff --git a/horsygui.py b/horsygui.py index d321066..abd3ec7 100644 --- a/horsygui.py +++ b/horsygui.py @@ -1,3 +1,5 @@ +import os +import subprocess import sys import math import webbrowser @@ -5,6 +7,7 @@ import modules.vars as horsy_vars from PyQt5 import QtWidgets import ctypes import modules.gui as gui +import requests # Hide console window (does not work on custom terminals like Windows Terminal) @@ -159,6 +162,28 @@ def upload_gui(): # Run functions on startup if __name__ == "__main__": + # Checking version + try: + f = open(horsy_vars.horsypath + 'apps/version', 'r') + 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: + 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) + 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') + UiMainWindow.close() + os.system('horsy_updater.exe horsygui') + sys.exit() + installed_apps() # Binds