diff --git a/build_bats/build-updater.bat b/build_bats/build-updater.bat new file mode 100644 index 0000000..239055c --- /dev/null +++ b/build_bats/build-updater.bat @@ -0,0 +1,5 @@ +cd .. +pip install -r requirements.txt +pyinstaller --noconfirm --icon "img/icon.ico" --onefile --console "horsy_updater.py" +rmdir /s /q __pycache__ +del horsy_updater.spec \ No newline at end of file diff --git a/build_bats/build-updater_clean.bat b/build_bats/build-updater_clean.bat new file mode 100644 index 0000000..d8c2ea8 --- /dev/null +++ b/build_bats/build-updater_clean.bat @@ -0,0 +1,7 @@ +cd .. +pip install -r requirements.txt +rmdir /s /q build +pyinstaller --noconfirm --icon "img/icon.ico" --onefile --console "horsy_updater.py" +rmdir /s /q __pycache__ +del horsy_updater.spec +rmdir /s /q build \ No newline at end of file diff --git a/dist.py b/dist.py index 9dce734..a56a781 100644 --- a/dist.py +++ b/dist.py @@ -3,6 +3,7 @@ import os os.system("xcopy /s /Y dist\horsy.exe bin\horsy.exe*") os.system("xcopy /s /Y dist\horsygui.exe bin\horsygui.exe*") os.system("xcopy /s /Y dist\horsy_installer.exe bin\installer-horsy-win.exe*") +os.system("xcopy /s /Y dist\horsy_updater.exe bin\horsy_updater.exe*") with open("web_vars/version", "r") as f_r: version = f_r.readline() diff --git a/horsy_installer.py b/horsy_installer.py index ecde3bf..ee4ec65 100644 --- a/horsy_installer.py +++ b/horsy_installer.py @@ -188,7 +188,7 @@ def install(): 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", - os.path.join(path_to_install) + '/horsy.exe'), )) + os.path.join(path_to_install) + '/horsygui.exe'), )) try: ui.logs_box.append("Starting tasks") for thread in threads: diff --git a/horsy_updater.py b/horsy_updater.py index e69de29..b648a50 100644 --- a/horsy_updater.py +++ b/horsy_updater.py @@ -0,0 +1,40 @@ +import argparse +import urllib.request +import threading +import ctypes +import sys +import os + +parser = argparse.ArgumentParser(description='horsy updater') +parser.add_argument('option', nargs='?') +args = parser.parse_args() +option = args.option + +path_to_install = os.popen('echo %HORSYPATH%').read().replace('\n', '') # Get installation folder + +if not os.path.exists(path_to_install): + os.makedirs(path_to_install) +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", + 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", + os.path.join(path_to_install) + '/horsygui.exe'), )) +try: + for thread in threads: + thread.start() +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", + os.path.join(path_to_install) + '/apps/version') + +for thread in threads: + thread.join() + +os.system(option)