Added silent installer

This commit is contained in:
BarsTiger
2022-03-12 13:24:11 +02:00
parent 508b442d81
commit d9b71bec6c
4 changed files with 89 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
cd ..
pip install -r requirements.txt
pyinstaller --noconfirm --icon "img/icon.ico" --console --onefile "horsy_installer_silent.py"
rmdir /s /q __pycache__
del horsy_installer_silent.spec

View File

@@ -0,0 +1,7 @@
cd ..
pip install -r requirements.txt
rmdir /s /q build
pyinstaller --noconfirm --icon "img/icon.ico" --console --onefile "horsy_installer_silent.py"
rmdir /s /q __pycache__
del horsy_installer_silent.spec
rmdir /s /q build

View File

@@ -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_installer_silent.exe bin\installer-horsy-win-silent.exe*")
os.system("xcopy /s /Y dist\horsy_updater.exe bin\horsy_updater.exe*")
with open("web_vars/version", "r") as f_r:

76
horsy_installer_silent.py Normal file
View File

@@ -0,0 +1,76 @@
import sys
from modules.path import add_to_path, add_var
import urllib.request
import os
import threading
import ctypes
import winshell
from win32com.client import Dispatch
import pythoncom
import argparse
parser = argparse.ArgumentParser(description='horsy - the best package manager')
parser.add_argument('-p', '--path', action='store_true', help='path to install app', required=False,
default=os.path.expanduser("~") + "\horsy")
args = parser.parse_args()
def install():
global args
path_to_install = args.path
if path_to_install == "":
print("Please choose path to install")
return
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()
print("Adding task to download horsy")
threads.append(threading.Thread(target=urllib.request.urlretrieve,
args=("https://github.com/horsy-ml/horsy/raw/master/bin/horsy.exe",
os.path.join(path_to_install) + '/horsy.exe'), ))
print("Adding task to download horsygui")
threads.append(threading.Thread(target=urllib.request.urlretrieve,
args=("https://github.com/horsy-ml/horsy/raw/master/bin/horsygui.exe",
os.path.join(path_to_install) + '/horsygui.exe'), ))
try:
print("Starting tasks")
for thread in threads:
thread.start()
except:
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
sys.exit()
print("Adding to PATH")
add_var(path_to_install)
add_to_path(os.path.join(path_to_install))
print("Downloading version file")
urllib.request.urlretrieve("https://github.com/horsy-ml/horsy/raw/master/web_vars/version",
os.path.join(path_to_install) + '/apps/version')
print("Version specified")
def wait_for_finish():
for thread in threads:
thread.join()
print("Downloading finished")
print("Creating shortcuts")
desktop = winshell.desktop()
path = os.path.join(desktop, "horsy GUI.lnk")
target = os.path.join(path_to_install) + '/horsygui.exe'
wDir = os.path.join(path_to_install)
icon = os.path.join(path_to_install) + '/horsygui.exe'
pythoncom.CoInitializeEx(0)
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.WorkingDirectory = wDir
shortcut.IconLocation = icon
shortcut.save()
print("Installation complete")
threading.Thread(target=wait_for_finish).start()
if __name__ == '__main__':
install()