From 4a095393d82504d3e9f6ff354f38f5ffc99704b6 Mon Sep 17 00:00:00 2001 From: gfdgd_xi <3025613752@qq.com> Date: Sun, 23 Oct 2022 22:19:23 +0800 Subject: [PATCH] =?UTF-8?q?=E2=80=BB7=E3=80=81=E5=AE=B9=E5=99=A8=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=85=8D=E7=BD=AE=E8=84=9A=E6=9C=AC=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=AF=84=E5=88=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AutoConfig.py | 129 +++++++++++++++++++++++ UI/AutoConfig.py | 10 +- UI/AutoConfig.ui | 16 ++- UI/__pycache__/AutoConfig.cpython-37.pyc | Bin 2536 -> 2765 bytes mainwindow.py | 1 + 5 files changed, 154 insertions(+), 2 deletions(-) diff --git a/AutoConfig.py b/AutoConfig.py index a908704..021290a 100755 --- a/AutoConfig.py +++ b/AutoConfig.py @@ -10,6 +10,7 @@ ################# # 引入所需的库 ################# +from fileinput import filename import os import sys import json @@ -21,6 +22,131 @@ from Model import * urlSources = "https://code.gitlink.org.cn/gfdgd_xi/wine-runner-list/raw/branch/master/auto" lists = [] +class ProgramRunStatusUpload(): + msgWindow = None + starLayout = None + fen = None + starList = [] + sha1Value = "" + programName = None + def ChangeStar(): + if ProgramRunStatusUpload.fen.currentIndex() > 5: + for i in ProgramRunStatusUpload.starList: + i.setText(f"") + return + for i in range(ProgramRunStatusUpload.fen.currentIndex()): + ProgramRunStatusUpload.starList[i].setText(f"") + head = ProgramRunStatusUpload.fen.currentIndex() + end = len(ProgramRunStatusUpload.starList) + for i in range(head, end): + ProgramRunStatusUpload.starList[i].setText(f"") + + def ShowWindow(sha="", title=""): + ProgramRunStatusUpload.starList = [] + ProgramRunStatusUpload.sha1Value = sha + ProgramRunStatusUpload.msgWindow = QtWidgets.QMainWindow() + msgWidget = QtWidgets.QWidget() + msgWidgetLayout = QtWidgets.QGridLayout() + ProgramRunStatusUpload.programName = QtWidgets.QLineEdit() + ProgramRunStatusUpload.fen = QtWidgets.QComboBox() + ProgramRunStatusUpload.starLayout = QtWidgets.QHBoxLayout() + upload = QtWidgets.QPushButton(QtCore.QCoreApplication.translate("U", "上传")) + upload.clicked.connect(ProgramRunStatusUpload.Upload) + if title != "": + ProgramRunStatusUpload.programName.setText(title) + ProgramRunStatusUpload.programName.setDisabled(True) + # 生成星星列表 + for i in [1, 1, 1, 1, 0]: + ProgramRunStatusUpload.starList.append(QtWidgets.QLabel(f"")) + ProgramRunStatusUpload.starLayout.addWidget(ProgramRunStatusUpload.starList[-1]) + ProgramRunStatusUpload.starLayout.addItem(QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)) + ProgramRunStatusUpload.programName.setPlaceholderText(QtCore.QCoreApplication.translate("U", "如果这个程序和程序名确实是合法还是检测到敏感词,改为“NULL”即可")) + ProgramRunStatusUpload.fen.addItems(["0分", + "1分", + "2分", + "3分", + "4分", + "5分"]) + ProgramRunStatusUpload.fen.setCurrentIndex(4) + ProgramRunStatusUpload.fen.currentIndexChanged.connect(ProgramRunStatusUpload.ChangeStar) + msgWidgetLayout.addWidget(QtWidgets.QLabel(QtCore.QCoreApplication.translate("U", "程序名:")), 0, 0) + msgWidgetLayout.addWidget(QtWidgets.QLabel(QtCore.QCoreApplication.translate("U", "评分:")), 1, 0) + msgWidgetLayout.addWidget(ProgramRunStatusUpload.programName, 0, 1) + msgWidgetLayout.addWidget(ProgramRunStatusUpload.fen, 1, 1) + msgWidgetLayout.addLayout(ProgramRunStatusUpload.starLayout, 2, 1) + msgWidgetLayout.addWidget(upload, 3, 1) + msgWidget.setLayout(msgWidgetLayout) + ProgramRunStatusUpload.msgWindow.setCentralWidget(msgWidget) + ProgramRunStatusUpload.msgWindow.setWindowTitle(QtCore.QCoreApplication.translate("U", "上传程序运行情况")) + ProgramRunStatusUpload.msgWindow.setWindowIcon(QtGui.QIcon(iconPath)) + ProgramRunStatusUpload.msgWindow.show() + + def Upload(): + try: + #if ProgramRunStatusUpload.sha1Value == "": + #ProgramRunStatusUpload.sha1Value = ProgramRunStatusUpload.GetSHA1(e2.currentText()) + QtWidgets.QMessageBox.information(None, QtCore.QCoreApplication.translate("U", "提示"), json.loads(requests.post("http://120.25.153.144:30250/bash", { + "BashName": ProgramRunStatusUpload.programName.text(), + "Fen": ProgramRunStatusUpload.fen.currentIndex() + }).text)["Error"]) + except: + traceback.print_exc() + QtWidgets.QMessageBox.critical(None, QtCore.QCoreApplication.translate("U", "错误"), QtCore.QCoreApplication.translate("U", "数据上传失败!")) + +class ProgramRunStatusShow(): + msgWindow = None + def ShowWindow(): + global lists + # 获取选中项 + try: + choose = ui.searchList.selectionModel().selectedIndexes()[0].data() + except: + QtWidgets.QMessageBox.critical(window, "错误", "您未选择任何配置文件") + return + fileName = "" + for i in lists: + print(i) + if i[0] == choose: + fileName = i[1] + break + try: + fenlists = requests.get(f"http://120.25.153.144/spark-deepin-wine-runner/bashapp/{fileName}/all.json").json() + #r = requests.get(base64.b64decode("aHR0cDovLzEyMC4yNS4xNTMuMTQ0L3NwYXJrLWRlZXBpbi13aW5lLXJ1bm5lci9hcHAv").decode("utf-8") + sha + base64.b64decode("L3RpdGxlLnR4dA==").decode("utf-8")) + #r.encoding = "utf-8" + #title = r.text + tipsInfo = "" + except: + #traceback.print_exc() + fenlists = [0, 0, 0, 0, 0] + tipsInfo = "暂时无人提交此脚本运行情况,是否立即提交?" + + maxHead = fenlists.index(max(fenlists)) + ProgramRunStatusShow.msgWindow = QtWidgets.QMainWindow() + msgWidget = QtWidgets.QWidget() + msgWidgetLayout = QtWidgets.QGridLayout() + starLayout = QtWidgets.QHBoxLayout() + uploadButton = QtWidgets.QPushButton(QtCore.QCoreApplication.translate("U", "点此上传运行情况")) + uploadButton.clicked.connect(lambda: ProgramRunStatusUpload.ShowWindow(fileName, fileName)) + msgWidgetLayout.addWidget(QtWidgets.QLabel(QtCore.QCoreApplication.translate("U", "综合评价:")), 0, 0) + msgWidgetLayout.addLayout(starLayout, 0, 1) + msgWidgetLayout.addWidget(QtWidgets.QLabel(tipsInfo), 1, 0, 1, 2) + #msgWidgetLayout.addWidget(QtWidgets.QLabel("" if dateVersion == "" else f"数据版本:{dateVersion}"), 2, 0, 1, 2) + msgWidgetLayout.addWidget(uploadButton, 3, 0, 1, 2) + end = 5 + if maxHead > 5: + for i in range(end): + starLayout.addWidget(QtWidgets.QLabel(f"")) + else: + for i in range(maxHead): + starLayout.addWidget(QtWidgets.QLabel(f"")) + head = maxHead + for i in range(head, end): + starLayout.addWidget(QtWidgets.QLabel(f"")) + msgWidget.setLayout(msgWidgetLayout) + ProgramRunStatusShow.msgWindow.setCentralWidget(msgWidget) + ProgramRunStatusShow.msgWindow.setWindowIcon(QtGui.QIcon(iconPath)) + #ProgramRunStatusShow.msgWindow.setWindowTitle(f"应用“{title}”的运行情况") + ProgramRunStatusShow.msgWindow.show() class Connect: def SearchBotton_Clicked(): @@ -119,12 +245,14 @@ if __name__ == "__main__": ui.setupUi(window) window.setWindowTitle(f"Wine 运行器 {version}——容器自动配置部署脚本") window.setWindowIcon(QtGui.QIcon(f"{programPath}/deepin-wine-runner.svg")) + iconPath = "{}/deepin-wine-runner.svg".format(programPath) window.show() # 连接信号和槽 ui.saerchBotton.clicked.connect(Connect.SearchBotton_Clicked) ui.runBotton.clicked.connect(Connect.RunBotton_Clicked) ui.openFile.triggered.connect(Connect.OpenFile_Triggered) ui.exitProgram.triggered.connect(window.close) + ui.getFen.clicked.connect(ProgramRunStatusShow.ShowWindow) # 解析云列表 try: # 获取列表 @@ -137,4 +265,5 @@ if __name__ == "__main__": except: traceback.print_exc() QtWidgets.QMessageBox.critical(window, "提示", "无法连接服务器") + app.exec_() \ No newline at end of file diff --git a/UI/AutoConfig.py b/UI/AutoConfig.py index 1418666..159b556 100644 --- a/UI/AutoConfig.py +++ b/UI/AutoConfig.py @@ -35,13 +35,19 @@ class Ui_MainWindow(object): self.horizontalLayout_2.setObjectName("horizontalLayout_2") spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem) + self.getFen = QtWidgets.QPushButton(self.centralwidget) + self.getFen.setObjectName("getFen") + self.horizontalLayout_2.addWidget(self.getFen) + self.uploadFen = QtWidgets.QPushButton(self.centralwidget) + self.uploadFen.setObjectName("uploadFen") + self.horizontalLayout_2.addWidget(self.uploadFen) self.runBotton = QtWidgets.QPushButton(self.centralwidget) self.runBotton.setObjectName("runBotton") self.horizontalLayout_2.addWidget(self.runBotton) self.verticalLayout_3.addLayout(self.horizontalLayout_2) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 36)) + self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 33)) self.menubar.setObjectName("menubar") self.menu = QtWidgets.QMenu(self.menubar) self.menu.setObjectName("menu") @@ -67,6 +73,8 @@ class Ui_MainWindow(object): MainWindow.setWindowTitle(_translate("MainWindow", "自动部署脚本")) self.searchTips.setText(_translate("MainWindow", "搜索内容(为空代表显示所有内容):")) self.saerchBotton.setText(_translate("MainWindow", "搜索")) + self.getFen.setText(_translate("MainWindow", "获取选中项的评分")) + self.uploadFen.setText(_translate("MainWindow", "提交选中项的评分")) self.runBotton.setText(_translate("MainWindow", "部署此方案")) self.menu.setTitle(_translate("MainWindow", "程序")) self.about.setText(_translate("MainWindow", "关于")) diff --git a/UI/AutoConfig.ui b/UI/AutoConfig.ui index 7b0ae10..f92ff37 100644 --- a/UI/AutoConfig.ui +++ b/UI/AutoConfig.ui @@ -54,6 +54,20 @@ + + + + 获取选中项的评分 + + + + + + + 提交选中项的评分 + + + @@ -71,7 +85,7 @@ 0 0 800 - 36 + 33 diff --git a/UI/__pycache__/AutoConfig.cpython-37.p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