GUI development

This commit is contained in:
BarsTiger
2022-01-26 21:18:35 +02:00
parent 9872f20ad5
commit 64f7e5c795
2 changed files with 110 additions and 70 deletions

View File

@@ -6,9 +6,6 @@ from PyQt5 import QtCore, QtGui, QtWidgets
import modules.gui as gui
from modules.console import cls
from modules.virustotal import add_to_cfg
from modules.uploader import upload
from modules.source import get_source
import modules.vars as horsy_vars
# Initialize GUI
@@ -90,6 +87,11 @@ def get_source_gui():
except:
return
def upload_gui():
from modules.uploader import upload
upload(True, ui)
# Run functions on startup
installed_apps()
@@ -100,6 +102,7 @@ ui.delete_button.clicked.connect(uninstall_app)
ui.search_button.clicked.connect(search_gui)
ui.install_button.clicked.connect(install_app)
ui.source_button.clicked.connect(get_source_gui)
ui.upload_button.clicked.connect(upload_gui)
# Handle GUI exiting to exit whole program

View File

@@ -16,7 +16,8 @@ def urlmatch(s):
return re.match("^https?://.*.(?:zip|exe)$", s) is not None
def upload():
def upload(is_gui=False, ui=None):
if not is_gui:
print('Welcome to the uploader')
print('Before starting, please make sure you have done your project and [blink]uploaded[/] it to any hosting '
'service or file sharing service')
@@ -91,16 +92,52 @@ def upload():
'run': run
}
# request = {
# "auth": {"email": "meshko_a@dlit.dp.ua", "password": "VeryGoodPassword"},
# "name": "testapp",
# "description": "Very good description",
# # "url": "https://github.com/Cactus-0/cabanchik/raw/main/dist/cabanchik.exe",
# "sourceUrl": "https://github.com/Cactus-0/cabanchik",
# "download": "https://www.python.org/ftp/python/3.10.2/python-3.10.2-amd64.exe",
# "install": "python-3.10.2-amd64.exe",
# "run": "cabanchik.exe"
# }
else:
auth = get_auth()
project_name = ui.packagename_box.text()
if not matches(project_name) or len(project_name) > 64 or len(project_name) < 3:
print('[red]Invalid project name[/red]')
return
description = ui.package_desc_box.toPlainText()
if len(description) > 256:
print('[red]Description is too long[/red]')
return
url = ui.url_of_exe_box.text()
if not urlmatch(url):
print('[red]Invalid file url, also it should end on .exe or .zip[/red]')
return
source_url = ui.source_url_box.text()
source_url = None if source_url == '' else source_url
download = ui.dependency_url_box.text()
if download == '':
download = None
elif not urlmatch(download):
print('[red]Invalid download url[/red]')
return
install = ui.dependency_run_box.text()
install = None if install == '' else install
run = ui.main_exe_box.text()
if run == '':
print('[red]Please, specify runtime[/red]')
return
request = {
'auth': auth,
'name': project_name,
'description': description,
'url': url,
'sourceUrl': source_url,
'download': download,
'install': install,
'run': run
}
r = None
while r is None: