Final refactor

This commit is contained in:
BarsTiger
2022-02-07 22:32:50 +02:00
parent 46b5329318
commit 7bb411871e
4 changed files with 13 additions and 4 deletions

View File

@@ -54,7 +54,8 @@ try:
os.system('horsy_updater.exe horsy') os.system('horsy_updater.exe horsy')
sys.exit(0) sys.exit(0)
except: except:
print('Horsy may be not installed correctly. Please reinstall it.') print('Horsy may be not installed correctly. Please reinstall it or stop other horsy instances. '
'If you installed it just now, please restart PC.')
isNoArgs = False isNoArgs = False

View File

@@ -221,11 +221,19 @@ def gui_package_edit():
# Run functions on startup # Run functions on startup
if __name__ == "__main__": if __name__ == "__main__":
# Checking directories and files
if not os.path.exists(horsy_vars.horsypath + 'apps'):
os.makedirs(horsy_vars.horsypath + 'apps')
if not os.path.isfile(horsy_vars.horsypath + 'config.cfg'):
with open(horsy_vars.horsypath + 'config.cfg', 'w') as f:
f.write('{}')
# Checking version # Checking version
try: try:
f = open(horsy_vars.horsypath + 'apps/version', 'r') f = open(horsy_vars.horsypath + 'apps/version', 'r')
except: except:
gui.popup('Error', 'Horsy may be not installed correctly. Please reinstall it.') gui.popup('Error', 'Horsy may be not installed correctly. Please reinstall it or stop another instances if '
'running. If you installed it just now, please restart PC.')
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.'

View File

@@ -123,7 +123,7 @@ def install(package):
with open('{1}apps/{0}.bat'.format(r['name'], horsy_vars.horsypath), 'w') as f: with open('{1}apps/{0}.bat'.format(r['name'], horsy_vars.horsypath), 'w') as f:
f.write(f"@ECHO off\n") f.write(f"@ECHO off\n")
f.write(f"{horsy_vars.horsypath[0:2:1]}\n") f.write(f"%horsypath:~0,1%:\n")
f.write(f"cd %horsypath%/apps/{r['name']}\n") f.write(f"cd %horsypath%/apps/{r['name']}\n")
f.write(f"{r['run']} %*\n") f.write(f"{r['run']} %*\n")

View File

@@ -114,7 +114,7 @@ def install(package):
with open('{1}apps/{0}.bat'.format(r['name'], horsy_vars.horsypath), 'w') as f: with open('{1}apps/{0}.bat'.format(r['name'], horsy_vars.horsypath), 'w') as f:
f.write(f"@ECHO off\n") f.write(f"@ECHO off\n")
f.write(f"{horsy_vars.horsypath[0:2:1]}\n") f.write(f"%horsypath:~0,1%:\n")
f.write(f"cd %horsypath%/apps/{r['name']}\n") f.write(f"cd %horsypath%/apps/{r['name']}\n")
f.write(f"{r['run']} %*\n") f.write(f"{r['run']} %*\n")