Console hide

This commit is contained in:
BarsTiger
2022-01-31 17:59:36 +02:00
parent 5138f10417
commit cb0450b70e
12 changed files with 52 additions and 27 deletions

View File

@@ -1,4 +0,0 @@
pip install -r requirements.txt
pyinstaller --noconfirm --icon "img/icon.ico" --windowed --onefile "horsy_installer.py"
rmdir /s /q __pycache__
del horsy_installer.spec

View File

@@ -1,3 +1,4 @@
cd ..
pip install -r requirements.txt pip install -r requirements.txt
pyinstaller --noconfirm --icon "img/icon.ico" --console --onefile "horsygui.py" pyinstaller --noconfirm --icon "img/icon.ico" --console --onefile "horsygui.py"
rmdir /s /q __pycache__ rmdir /s /q __pycache__

View File

@@ -1,3 +1,4 @@
cd ..
pip install -r requirements.txt pip install -r requirements.txt
rmdir /s /q build rmdir /s /q build
pyinstaller --noconfirm --icon "img/icon.ico" --console --onefile "horsygui.py" pyinstaller --noconfirm --icon "img/icon.ico" --console --onefile "horsygui.py"

View File

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

View File

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

View File

@@ -1,3 +1,4 @@
cd ..
pip install -r requirements.txt pip install -r requirements.txt
pyinstaller --noconfirm --icon "img/icon.ico" --console --onefile "horsy.py" pyinstaller --noconfirm --icon "img/icon.ico" --console --onefile "horsy.py"
rmdir /s /q __pycache__ rmdir /s /q __pycache__

View File

@@ -1,3 +1,4 @@
cd ..
pip install -r requirements.txt pip install -r requirements.txt
rmdir /s /q build rmdir /s /q build
pyinstaller --noconfirm --icon "img/icon.ico" --console --onefile "horsy.py" pyinstaller --noconfirm --icon "img/icon.ico" --console --onefile "horsy.py"

View File

@@ -4,8 +4,8 @@ from modules.path import add_to_path, add_var
import modules.images import modules.images
import urllib.request import urllib.request
import os import os
import ctypes
import threading import threading
import ctypes
class Ui_MainWindow(object): class Ui_MainWindow(object):
@@ -159,6 +159,8 @@ class Ui_MainWindow(object):
self.centralwidget, 'Installation folder')) + "\horsy").replace("/", "\\").replace('\\\\', '\\')) self.centralwidget, 'Installation folder')) + "\horsy").replace("/", "\\").replace('\\\\', '\\'))
ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 0)
app = QtWidgets.QApplication(sys.argv) app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow() MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow() ui = Ui_MainWindow()
@@ -175,27 +177,42 @@ def install():
return return
if not os.path.exists(path_to_install): if not os.path.exists(path_to_install):
os.makedirs(path_to_install) os.makedirs(path_to_install)
try: if not os.path.exists(path_to_install + "\\apps"):
ui.logs_box.append("Downloading horsy") os.makedirs(path_to_install + "\\apps")
threading.Thread(target=urllib.request.urlretrieve, threads = list()
ui.logs_box.append("Adding task to download horsy")
threads.append(threading.Thread(target=urllib.request.urlretrieve,
args=("https://github.com/BarsTiger/horsy/raw/master/bin/horsy.exe", args=("https://github.com/BarsTiger/horsy/raw/master/bin/horsy.exe",
os.path.join(path_to_install) + '/horsy.exe'),).start() os.path.join(path_to_install) + '/horsy.exe'), ))
if ui.install_gui_check.isChecked():
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'), ))
try:
ui.logs_box.append("Starting tasks")
for thread in threads:
thread.start()
except: 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()
if ui.install_gui_check.isChecked(): ui.logs_box.append("Adding to PATH")
try:
ui.logs_box.append("Installing horsygui")
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'), ).start()
except:
ui.logs_box.append("Error while installing horsygui")
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")
urllib.request.urlretrieve("https://github.com/BarsTiger/horsy/raw/master/web_vars/version",
os.path.join(path_to_install) + '/apps/version')
ui.logs_box.append("Version specified")
def wait_for_finish():
for thread in threads:
thread.join()
ui.logs_box.append("Downloading finished")
ui.logs_box.append("Installation complete") ui.logs_box.append("Installation complete")
threading.Thread(target=wait_for_finish).start()
ui.choose_path_button.clicked.connect(ui.openFile) ui.choose_path_button.clicked.connect(ui.openFile)
ui.install_button.clicked.connect(install) ui.install_button.clicked.connect(install)

View File

@@ -2,10 +2,14 @@ import sys
import math import math
import webbrowser import webbrowser
import modules.vars as horsy_vars import modules.vars as horsy_vars
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtWidgets
import ctypes
import modules.gui as gui import modules.gui as gui
# Hide console window (does not work on custom terminals like Windows Terminal)
ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 0)
# Initialize GUI # Initialize GUI
if __name__ == "__main__": if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv) app = QtWidgets.QApplication(sys.argv)

View File

@@ -2,6 +2,7 @@
import os import os
os.popen('cls') os.popen('cls')
existing_path_value_l = os.popen('PATH').read()[5:].replace('\n', '') # Get the existing path value existing_path_value_l = os.popen('PATH').read()[5:].replace('\n', '') # Get the existing path value
print('Existing path value: ' + existing_path_value_l)
existing_path_value_s = set() existing_path_value_s = set()
for i in existing_path_value_l.split(';'): for i in existing_path_value_l.split(';'):
existing_path_value_s.add(i + ';') existing_path_value_s.add(i + ';')
@@ -11,8 +12,6 @@ existing_path_value = str()
for i in existing_path_value_s: for i in existing_path_value_s:
existing_path_value += i existing_path_value += i
print('Existing path value: ' + existing_path_value)
def add_to_path(program_path: str): def add_to_path(program_path: str):
import winreg import winreg
@@ -20,13 +19,11 @@ def add_to_path(program_path: str):
with winreg.OpenKey(root, "Environment", 0, winreg.KEY_ALL_ACCESS) as key: # Open the environment key with winreg.OpenKey(root, "Environment", 0, winreg.KEY_ALL_ACCESS) as key: # Open the environment key
new_path_value = existing_path_value + f'{";" if existing_path_value[-1] != ";" else ""}' + \ new_path_value = existing_path_value + f'{";" if existing_path_value[-1] != ";" else ""}' + \
program_path + ';' + program_path + "\\apps;" # Create new program_path + ';' + program_path + "\\apps;" # Create new
print(new_path_value)
winreg.SetValueEx(key, "PATH", 0, winreg.REG_EXPAND_SZ, new_path_value) # Update the path value winreg.SetValueEx(key, "PATH", 0, winreg.REG_EXPAND_SZ, new_path_value) # Update the path value
def add_var(horsy_path: str): def add_var(horsy_path: str):
import winreg import winreg
with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as root: # Get the current user's registry with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as root: # Get the current user's registry
with winreg.OpenKey(root, "Environment", 0, winreg.KEY_ALL_ACCESS) as key: # Open the environment key with winreg.OpenKey(root, "Environment", 0, winreg.KEY_ALL_ACCESS) as key: # Open the environment key
winreg.SetValueEx(key, "HORSYPATH", 0, winreg.REG_EXPAND_SZ, horsy_path) # Update the path value winreg.SetValueEx(key, "HORSYPATH", 0, winreg.REG_EXPAND_SZ, horsy_path) # Update the path value

View File

@@ -5,3 +5,4 @@ Pyinstaller
tqdm tqdm
algoliasearch algoliasearch
PyQt5 PyQt5
easygui

View File

@@ -1 +1 @@
0 1