New start script system

This commit is contained in:
BarsTiger
2022-02-28 16:31:48 +02:00
parent 7fe161fc42
commit 8761dddd71
5 changed files with 12 additions and 13 deletions

View File

@@ -164,7 +164,7 @@ def dislike_gui():
def upload_gui(): def upload_gui():
from modules.uploader import upload from modules.uploader import upload
gui.popup('Upload', str(upload(True, ui, login_ui, UiMainWindow))) gui.popup('Upload', str(upload(True, ui)))
def change_password_gui(): def change_password_gui():

View File

@@ -665,7 +665,7 @@ class Ui_MainWindow(object):
self.dependency_run_box.setPlaceholderText( self.dependency_run_box.setPlaceholderText(
_translate("MainWindow", "Dependency run (run this during installation)")) _translate("MainWindow", "Dependency run (run this during installation)"))
self.main_exe_box.setPlaceholderText( self.main_exe_box.setPlaceholderText(
_translate("MainWindow", "Main executable command (file.exe, python main.py, etc)")) _translate("MainWindow", "Command ($appdir$\\file.exe, python $appdir$\\main.py, etc)"))
self.upload_button.setText(_translate("MainWindow", "Upload")) self.upload_button.setText(_translate("MainWindow", "Upload"))
self.safetywarning_message.setHtml(_translate("MainWindow", self.safetywarning_message.setHtml(_translate("MainWindow",
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
@@ -908,7 +908,7 @@ class Ui_PackageWindow(object):
MainWindow.setWindowTitle(_translate("MainWindow", "horsy - editing package")) MainWindow.setWindowTitle(_translate("MainWindow", "horsy - editing package"))
self.packagename_box.setPlaceholderText(_translate("MainWindow", "Editing package")) self.packagename_box.setPlaceholderText(_translate("MainWindow", "Editing package"))
self.main_exe_box.setPlaceholderText( self.main_exe_box.setPlaceholderText(
_translate("MainWindow", "Main executable command (file.exe, python main.py, etc)")) _translate("MainWindow", "Main executable command ($appdir$\\file.exe, python $appdir$\\main.py, etc)"))
self.source_url_box.setPlaceholderText( self.source_url_box.setPlaceholderText(
_translate("MainWindow", "Url of source (project on GitHub, source archive)")) _translate("MainWindow", "Url of source (project on GitHub, source archive)"))
self.url_of_exe_box.setPlaceholderText(_translate("MainWindow", "Url of executable (ends on .exe or .zip)")) self.url_of_exe_box.setPlaceholderText(_translate("MainWindow", "Url of executable (ends on .exe or .zip)"))

View File

@@ -82,6 +82,7 @@ def install(package):
download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) download_ui.logs_box.moveCursor(QtGui.QTextCursor.End)
unzip('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath), unzip('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath),
'{1}apps/{0}'.format(r['name'], horsy_vars.horsypath)) '{1}apps/{0}'.format(r['name'], horsy_vars.horsypath))
os.remove('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath))
download_ui.logs_box.append("") download_ui.logs_box.append("")
download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) download_ui.logs_box.moveCursor(QtGui.QTextCursor.End)
@@ -129,9 +130,7 @@ def install(package):
download_ui.logs_box.append("Generating launch script") download_ui.logs_box.append("Generating launch script")
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"%horsypath:~0,1%:\n") f.write(f"""{r['run'].replace('$appdir$', f'%horsypath%/apps/{r["name"]}')} %*\n""")
f.write(f"cd %horsypath%/apps/{r['name']}\n")
f.write(f"{r['run']} %*\n")
download_ui.logs_box.append("") download_ui.logs_box.append("")
download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) download_ui.logs_box.moveCursor(QtGui.QTextCursor.End)

View File

@@ -51,6 +51,7 @@ def install(package):
print(f"Extracting {r['url'].split('/')[-1]}") print(f"Extracting {r['url'].split('/')[-1]}")
unzip('{2}apps\{0}\{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath), unzip('{2}apps\{0}\{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath),
'{1}apps\{0}'.format(r['name'], horsy_vars.horsypath)) '{1}apps\{0}'.format(r['name'], horsy_vars.horsypath))
os.remove('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath))
print() print()
# Scan dependencies # Scan dependencies
@@ -77,9 +78,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"%horsypath:~0,1%:\n") f.write(f"""{r['run'].replace('$appdir$', f'%horsypath%/apps/{r["name"]}')} %*\n""")
f.write(f"cd %horsypath%/apps/{r['name']}\n")
f.write(f"{r['run']} %*\n")
# Done message # Done message
print(f"[green][OK] All done![/]") print(f"[green][OK] All done![/]")

View File

@@ -56,8 +56,8 @@ def upload(is_gui=False, ui=None):
source_url = input('> ') source_url = input('> ')
source_url = None if source_url == '' else source_url source_url = None if source_url == '' else source_url
print('If your app needs any dependencies, please paste its link here. It can be exe of installer from official ' print('If your app needs any dependencies, please paste its link here. It can be exe of installer from official'
'site. If you don\'t want to add it, just press Enter') ' site. If you don\'t want to add it, just press Enter')
download = None download = None
while download is None: while download is None:
download = input('> ') download = input('> ')
@@ -73,8 +73,9 @@ def upload(is_gui=False, ui=None):
install = input('> ') install = input('> ')
install = None if install == '' else install install = None if install == '' else install
print('Please specify main executable command. It can be executable file name (some-file.exe) or command, that ' print('Please specify main executable command. It can be executable file name ($appdir$\\some-file.exe) or '
'launches your script (python some-file.py, etc)') 'command, that launches your script (python $appdir$\\some-file.py, etc). $appdir$ will be replaced '
'with application directory. It is nessesary to add!')
run = None run = None
while run is None: while run is None:
run = input('> ') run = input('> ')