From 1cf1a188cf712e1a313f99fa585cd568909e6045 Mon Sep 17 00:00:00 2001 From: BarsTiger Date: Fri, 28 Jan 2022 20:32:18 +0200 Subject: [PATCH] Installer development --- horsy.py | 30 ++++--- horsy_installer.py | 174 ++++++++++++++++++++++++++++++++++++++++- horsygui.py | 17 +++- modules/gui.py | 15 ++++ uis/horsy_installer.py | 163 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 384 insertions(+), 15 deletions(-) create mode 100644 uis/horsy_installer.py diff --git a/horsy.py b/horsy.py index 498565b..24d235b 100644 --- a/horsy.py +++ b/horsy.py @@ -21,18 +21,6 @@ args = parser.parse_args() option = args.option app = args.app -# 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 -with open(horsy_vars.horsypath + 'apps/version', 'r') as f: - version = f.read() - - # Displaying the logo os.system('title horsy') cls() @@ -46,6 +34,24 @@ print(''' |__| |__||_______||___| |_||_______| |___| Search powered by Algolia ''') + +# 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 +try: + with open(horsy_vars.horsypath + 'apps/version', 'r') as f: + version = int(f.read()) + if int(requests.get('https://github.com/BarsTiger/horsy/raw/master/web_vars/version').text) > version: + print('New version available!') +except: + print('Horsy may be not installed correctly. Please reinstall it.') + + isNoArgs = False # Checking if the user has a new VT key diff --git a/horsy_installer.py b/horsy_installer.py index b41e3ee..579b79c 100644 --- a/horsy_installer.py +++ b/horsy_installer.py @@ -1 +1,173 @@ -print(1) \ No newline at end of file +from PyQt5 import QtCore, QtGui, QtWidgets +import sys +from modules.path import add_to_path, add_var +import modules.images +import os + + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(502, 364) + MainWindow.setMinimumSize(QtCore.QSize(502, 364)) + MainWindow.setMaximumSize(QtCore.QSize(502, 364)) + MainWindow.setWindowOpacity(0.98) + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap(":/images/horsy_white32x32.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + MainWindow.setWindowIcon(icon) + MainWindow.setStyleSheet("QWidget{\n" + " background-color: rgb(30, 30, 30);\n" + "}\n" + "") + self.centralwidget = QtWidgets.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + self.horsy_logo_lefttop = QtWidgets.QLabel(self.centralwidget) + self.horsy_logo_lefttop.setGeometry(QtCore.QRect(10, 10, 32, 32)) + self.horsy_logo_lefttop.setStyleSheet("background: none;") + self.horsy_logo_lefttop.setText("") + self.horsy_logo_lefttop.setPixmap(QtGui.QPixmap(":/images/horsy_white32x32.png")) + self.horsy_logo_lefttop.setObjectName("horsy_logo_lefttop") + self.path_box = QtWidgets.QLineEdit(self.centralwidget) + self.path_box.setGeometry(QtCore.QRect(20, 70, 351, 51)) + self.path_box.setStyleSheet("background-color: rgb(74, 76, 83);\n" + "border-radius: 5px; \n" + "color: rgb(242, 242, 242);") + self.path_box.setInputMask("") + self.path_box.setEchoMode(QtWidgets.QLineEdit.Normal) + self.path_box.setObjectName("path_box") + self.choose_path_button = QtWidgets.QPushButton(self.centralwidget) + self.choose_path_button.setEnabled(True) + self.choose_path_button.setGeometry(QtCore.QRect(380, 70, 101, 50)) + self.choose_path_button.setMinimumSize(QtCore.QSize(0, 50)) + self.choose_path_button.setStyleSheet("QPushButton {\n" + " color: rgb(204, 204, 204);\n" + " border-width: 1px;\n" + " border-radius:6px;\n" + " border-style: solid;\n" + " background-color: rgb(28, 30, 33);\n" + " border-color: rgb(66, 143, 225);\n" + "}\n" + "QPushButton:hover{\n" + " border-width: 2px;\n" + "}\n" + "QPushButton:pressed{\n" + " background-color: rgb(50, 60, 63);\n" + "}\n" + "QPushButton:disabled{\n" + " border-width: 0px;\n" + " background-color: rgb(92, 99, 109);\n" + "}") + self.choose_path_button.setObjectName("choose_path_button") + self.horsy_text_lefttop = QtWidgets.QLabel(self.centralwidget) + self.horsy_text_lefttop.setGeometry(QtCore.QRect(50, 10, 231, 30)) + self.horsy_text_lefttop.setStyleSheet("color: white;\n" + "font: 20pt \"MS Shell Dlg 2\";\n" + "background: none;") + self.horsy_text_lefttop.setObjectName("horsy_text_lefttop") + self.path_message = QtWidgets.QTextBrowser(self.centralwidget) + self.path_message.setGeometry(QtCore.QRect(20, 50, 321, 21)) + self.path_message.setStyleSheet("color: white;\n" + "border: none;\n" + "background-color: rgba(255, 255, 255, 0);") + self.path_message.setAcceptRichText(False) + self.path_message.setTextInteractionFlags(QtCore.Qt.NoTextInteraction) + self.path_message.setObjectName("path_message") + self.install_horsy_chech = QtWidgets.QCheckBox(self.centralwidget) + self.install_horsy_chech.setEnabled(False) + self.install_horsy_chech.setGeometry(QtCore.QRect(20, 130, 91, 17)) + self.install_horsy_chech.setStyleSheet("color: white;") + self.install_horsy_chech.setChecked(True) + self.install_horsy_chech.setObjectName("install_horsy_chech") + self.install_gui_check = QtWidgets.QCheckBox(self.centralwidget) + self.install_gui_check.setEnabled(True) + self.install_gui_check.setGeometry(QtCore.QRect(30, 150, 111, 17)) + self.install_gui_check.setStyleSheet("color: white;") + self.install_gui_check.setChecked(True) + self.install_gui_check.setObjectName("install_gui_check") + self.install_button = QtWidgets.QPushButton(self.centralwidget) + self.install_button.setEnabled(True) + self.install_button.setGeometry(QtCore.QRect(150, 300, 201, 50)) + self.install_button.setMinimumSize(QtCore.QSize(0, 50)) + self.install_button.setStyleSheet("QPushButton {\n" + " color: rgb(204, 204, 204);\n" + " border-width: 1px;\n" + " border-radius:6px;\n" + " border-style: solid;\n" + " background-color: rgb(28, 30, 33);\n" + " border-color: rgb(66, 143, 225);\n" + "}\n" + "QPushButton:hover{\n" + " border-width: 2px;\n" + "}\n" + "QPushButton:pressed{\n" + " background-color: rgb(50, 60, 63);\n" + "}\n" + "QPushButton:disabled{\n" + " border-width: 0px;\n" + " background-color: rgb(92, 99, 109);\n" + "}") + self.install_button.setObjectName("install_button") + self.logs_box = QtWidgets.QTextBrowser(self.centralwidget) + self.logs_box.setGeometry(QtCore.QRect(20, 180, 461, 101)) + self.logs_box.setMinimumSize(QtCore.QSize(0, 0)) + self.logs_box.setMaximumSize(QtCore.QSize(1000, 1000)) + self.logs_box.setStyleSheet("background-color: rgb(74, 76, 83);\n" + "border-radius: 5px; \n" + "color: rgb(242, 242, 242);") + self.logs_box.setAcceptRichText(False) + self.logs_box.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) + self.logs_box.setObjectName("logs_box") + self.label = QtWidgets.QLabel(self.centralwidget) + self.label.setGeometry(QtCore.QRect(20, 150, 16, 16)) + self.label.setStyleSheet("color: white;\n" + "background: none") + self.label.setObjectName("label") + MainWindow.setCentralWidget(self.centralwidget) + + self.retranslateUi(MainWindow) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + _translate = QtCore.QCoreApplication.translate + MainWindow.setWindowTitle(_translate("MainWindow", "horsy - installation")) + self.path_box.setPlaceholderText(_translate("MainWindow", "Installation folder, apps will be stored here")) + self.choose_path_button.setText(_translate("MainWindow", "Choose path")) + self.horsy_text_lefttop.setText(_translate("MainWindow", "horsy - installation")) + self.path_message.setHtml(_translate("MainWindow", + "\n" + "\n" + "

Installation folder, apps will be stored here

")) + self.install_horsy_chech.setText(_translate("MainWindow", "Install horsy")) + self.install_gui_check.setText(_translate("MainWindow", "Install horsy GUI")) + self.install_button.setText(_translate("MainWindow", "Install")) + self.logs_box.setHtml(_translate("MainWindow", + "\n" + "\n" + "


")) + self.logs_box.setPlaceholderText(_translate("MainWindow", "Logs")) + self.label.setText(_translate("MainWindow", "-")) + + def openFile(self, MainWindow): + self.path_box.setText(str(QtWidgets.QFileDialog.getExistingDirectory( + self.centralwidget, 'Installation folder')[0])) + + +app = QtWidgets.QApplication(sys.argv) +MainWindow = QtWidgets.QMainWindow() +ui = Ui_MainWindow() +ui.setupUi(MainWindow) +ui.path_box.setText(os.path.expanduser("~") + "\horsy") +MainWindow.show() + + +def install(): + pass + + +ui.choose_path_button.clicked.connect(ui.openFile) + +sys.exit(app.exec_()) diff --git a/horsygui.py b/horsygui.py index 446125e..749a8ba 100644 --- a/horsygui.py +++ b/horsygui.py @@ -1,5 +1,7 @@ import sys import math +import webbrowser +import modules.vars as horsy_vars from PyQt5 import QtCore, QtGui, QtWidgets import modules.gui as gui @@ -8,7 +10,6 @@ import modules.gui as gui if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) - UiMainWindow = QtWidgets.QMainWindow() ui = gui.Ui_MainWindow() ui.setupUi(UiMainWindow) @@ -24,10 +25,12 @@ download_ui.setupUi(UiDownloadWindow) if __name__ == "__main__": UiMainWindow.show() + # Functions def refresh_gui(): installed_apps() + def installed_apps(): from modules.manager import apps_list ui.installed_table.clear() @@ -37,6 +40,7 @@ def installed_apps(): for i in range(len(apps)): ui.installed_table.setItem(i // 4, i % 4, QtWidgets.QTableWidgetItem(str(apps[i]))) + def update_app(): try: app_name = ui.installed_table.currentItem().text() @@ -48,6 +52,7 @@ def update_app(): except: return + def uninstall_app(): try: app_name = ui.installed_table.currentItem().text() @@ -60,6 +65,7 @@ def uninstall_app(): except: return + def search_gui(): from modules.search import search search_query = ui.search_box.toPlainText() @@ -73,6 +79,7 @@ def search_gui(): for i in range(len(found)): ui.search_table.setItem(i // 4, i % 4, QtWidgets.QTableWidgetItem(str(found[i]))) + def install_app(): from modules.gui_manager import install try: @@ -84,6 +91,7 @@ def install_app(): except: return + def get_source_gui(): from modules.source import get_source try: @@ -97,6 +105,7 @@ def get_source_gui(): except: return + def info_gui(): from modules.search import info try: @@ -110,6 +119,7 @@ def info_gui(): except: return + def like_gui(): from modules.liker import like try: @@ -123,6 +133,7 @@ def like_gui(): except: return + def dislike_gui(): from modules.liker import dislike try: @@ -136,6 +147,7 @@ def dislike_gui(): except: return + def upload_gui(): from modules.uploader import upload gui.popup('Upload', str(upload(True, ui, login_ui, UiMainWindow))) @@ -157,7 +169,8 @@ if __name__ == "__main__": ui.like_button.clicked.connect(like_gui) ui.dislike_button.clicked.connect(dislike_gui) ui.upload_button.clicked.connect(upload_gui) - + ui.regmessage_button.clicked.connect(lambda: webbrowser.open(f"{horsy_vars.protocol}{horsy_vars.server_url}" + f"/registration")) # Handle GUI exiting to exit whole program sys.exit(app.exec_()) diff --git a/modules/gui.py b/modules/gui.py index 2beb39d..ddee137 100644 --- a/modules/gui.py +++ b/modules/gui.py @@ -95,6 +95,21 @@ class Ui_MainWindow(object): self.username_box.setText("") self.username_box.setReadOnly(True) self.username_box.setObjectName("username_box") + self.regmessage_box = QtWidgets.QLineEdit(self.account_tab) + self.regmessage_box.setGeometry(QtCore.QRect(720, 110, 151, 31)) + self.regmessage_box.setStyleSheet("background-color: rgb(74, 76, 83);\n" + "border-radius: 5px; \n" + "color: rgb(27, 166, 221);") + self.regmessage_box.setText(" Still not registered? Click here") + self.regmessage_box.setReadOnly(True) + self.regmessage_box.setObjectName("regmessage_box") + self.regmessage_button = QtWidgets.QPushButton(self.account_tab) + self.regmessage_button.setGeometry(QtCore.QRect(720, 110, 151, 31)) + self.regmessage_button.setStyleSheet("background-color: rgb(0, 0, 0, 0);\n" + "border-color: rgb(0, 0, 0, 0);\n" + "color: rgb(0, 0, 0, 0);") + self.regmessage_button.setText("") + self.regmessage_button.setObjectName("regmessage_button") self.changeemail_button = QtWidgets.QPushButton(self.account_tab) self.changeemail_button.setEnabled(True) self.changeemail_button.setGeometry(QtCore.QRect(360, 20, 151, 50)) diff --git a/uis/horsy_installer.py b/uis/horsy_installer.py new file mode 100644 index 0000000..5be5816 --- /dev/null +++ b/uis/horsy_installer.py @@ -0,0 +1,163 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'D:\RAZNOE\prgrming\horsy\Source\client\uis\horsy_installer.ui' +# +# Created by: PyQt5 UI code generator 5.15.6 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(502, 364) + MainWindow.setMinimumSize(QtCore.QSize(502, 364)) + MainWindow.setMaximumSize(QtCore.QSize(502, 364)) + MainWindow.setWindowOpacity(0.98) + MainWindow.setStyleSheet("QWidget{\n" +" background-color: rgb(30, 30, 30);\n" +"}\n" +"") + self.centralwidget = QtWidgets.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + self.horsy_logo_lefttop = QtWidgets.QLabel(self.centralwidget) + self.horsy_logo_lefttop.setGeometry(QtCore.QRect(10, 10, 32, 32)) + self.horsy_logo_lefttop.setStyleSheet("background: none;") + self.horsy_logo_lefttop.setText("") + self.horsy_logo_lefttop.setPixmap(QtGui.QPixmap("D:\\RAZNOE\\prgrming\\horsy\\Source\\client\\uis\\../img/horsy_white32x32.png")) + self.horsy_logo_lefttop.setObjectName("horsy_logo_lefttop") + self.path_box = QtWidgets.QLineEdit(self.centralwidget) + self.path_box.setGeometry(QtCore.QRect(20, 70, 351, 51)) + self.path_box.setStyleSheet("background-color: rgb(74, 76, 83);\n" +"border-radius: 5px; \n" +"color: rgb(242, 242, 242);") + self.path_box.setInputMask("") + self.path_box.setEchoMode(QtWidgets.QLineEdit.Normal) + self.path_box.setObjectName("path_box") + self.choose_path_button = QtWidgets.QPushButton(self.centralwidget) + self.choose_path_button.setEnabled(True) + self.choose_path_button.setGeometry(QtCore.QRect(380, 70, 101, 50)) + self.choose_path_button.setMinimumSize(QtCore.QSize(0, 50)) + self.choose_path_button.setStyleSheet("QPushButton {\n" +" color: rgb(204, 204, 204);\n" +" border-width: 1px;\n" +" border-radius:6px;\n" +" border-style: solid;\n" +" background-color: rgb(28, 30, 33);\n" +" border-color: rgb(66, 143, 225);\n" +"}\n" +"QPushButton:hover{\n" +" border-width: 2px;\n" +"}\n" +"QPushButton:pressed{\n" +" background-color: rgb(50, 60, 63);\n" +"}\n" +"QPushButton:disabled{\n" +" border-width: 0px;\n" +" background-color: rgb(92, 99, 109);\n" +"}") + self.choose_path_button.setObjectName("choose_path_button") + self.horsy_text_lefttop = QtWidgets.QLabel(self.centralwidget) + self.horsy_text_lefttop.setGeometry(QtCore.QRect(50, 10, 231, 30)) + self.horsy_text_lefttop.setStyleSheet("color: white;\n" +"font: 20pt \"MS Shell Dlg 2\";\n" +"background: none;") + self.horsy_text_lefttop.setObjectName("horsy_text_lefttop") + self.path_message = QtWidgets.QTextBrowser(self.centralwidget) + self.path_message.setGeometry(QtCore.QRect(20, 50, 321, 21)) + self.path_message.setStyleSheet("color: white;\n" +"border: none;\n" +"background-color: rgba(255, 255, 255, 0);") + self.path_message.setAcceptRichText(False) + self.path_message.setTextInteractionFlags(QtCore.Qt.NoTextInteraction) + self.path_message.setObjectName("path_message") + self.install_horsy_chech = QtWidgets.QCheckBox(self.centralwidget) + self.install_horsy_chech.setEnabled(False) + self.install_horsy_chech.setGeometry(QtCore.QRect(20, 130, 91, 17)) + self.install_horsy_chech.setStyleSheet("color: white;") + self.install_horsy_chech.setChecked(True) + self.install_horsy_chech.setObjectName("install_horsy_chech") + self.install_gui_check = QtWidgets.QCheckBox(self.centralwidget) + self.install_gui_check.setEnabled(True) + self.install_gui_check.setGeometry(QtCore.QRect(30, 150, 111, 17)) + self.install_gui_check.setStyleSheet("color: white;") + self.install_gui_check.setChecked(True) + self.install_gui_check.setObjectName("install_gui_check") + self.install_button = QtWidgets.QPushButton(self.centralwidget) + self.install_button.setEnabled(True) + self.install_button.setGeometry(QtCore.QRect(150, 300, 201, 50)) + self.install_button.setMinimumSize(QtCore.QSize(0, 50)) + self.install_button.setStyleSheet("QPushButton {\n" +" color: rgb(204, 204, 204);\n" +" border-width: 1px;\n" +" border-radius:6px;\n" +" border-style: solid;\n" +" background-color: rgb(28, 30, 33);\n" +" border-color: rgb(66, 143, 225);\n" +"}\n" +"QPushButton:hover{\n" +" border-width: 2px;\n" +"}\n" +"QPushButton:pressed{\n" +" background-color: rgb(50, 60, 63);\n" +"}\n" +"QPushButton:disabled{\n" +" border-width: 0px;\n" +" background-color: rgb(92, 99, 109);\n" +"}") + self.install_button.setObjectName("install_button") + self.logs_box = QtWidgets.QTextBrowser(self.centralwidget) + self.logs_box.setGeometry(QtCore.QRect(20, 180, 461, 101)) + self.logs_box.setMinimumSize(QtCore.QSize(0, 0)) + self.logs_box.setMaximumSize(QtCore.QSize(1000, 1000)) + self.logs_box.setStyleSheet("background-color: rgb(74, 76, 83);\n" +"border-radius: 5px; \n" +"color: rgb(242, 242, 242);") + self.logs_box.setAcceptRichText(False) + self.logs_box.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) + self.logs_box.setObjectName("logs_box") + self.label = QtWidgets.QLabel(self.centralwidget) + self.label.setGeometry(QtCore.QRect(20, 150, 16, 16)) + self.label.setStyleSheet("color: white;\n" +"background: none") + self.label.setObjectName("label") + MainWindow.setCentralWidget(self.centralwidget) + + self.retranslateUi(MainWindow) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + _translate = QtCore.QCoreApplication.translate + MainWindow.setWindowTitle(_translate("MainWindow", "horsy - installation")) + self.path_box.setPlaceholderText(_translate("MainWindow", "Installation folder, apps will be stored here")) + self.choose_path_button.setText(_translate("MainWindow", "Choose path")) + self.horsy_text_lefttop.setText(_translate("MainWindow", "horsy - installation")) + self.path_message.setHtml(_translate("MainWindow", "\n" +"\n" +"

Installation folder, apps will be stored here

")) + self.install_horsy_chech.setText(_translate("MainWindow", "Install horsy")) + self.install_gui_check.setText(_translate("MainWindow", "Install horsy GUI")) + self.install_button.setText(_translate("MainWindow", "Install")) + self.logs_box.setHtml(_translate("MainWindow", "\n" +"\n" +"


")) + self.logs_box.setPlaceholderText(_translate("MainWindow", "Logs")) + self.label.setText(_translate("MainWindow", "-")) + + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + MainWindow = QtWidgets.QMainWindow() + ui = Ui_MainWindow() + ui.setupUi(MainWindow) + MainWindow.show() + sys.exit(app.exec_())