Final refactor
This commit is contained in:
3
horsy.py
3
horsy.py
@@ -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
|
||||||
|
|||||||
10
horsygui.py
10
horsygui.py
@@ -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.'
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user