uengine-runner/ProgramFen.py

132 lines
7.2 KiB
Python
Raw Permalink Normal View History

2023-01-14 13:55:25 +08:00
#!/usr/bin/env python3
import os
import sys
import base64
import traceback
2023-01-14 14:10:50 +08:00
import requests
2023-01-14 13:55:25 +08:00
import PyQt5.QtGui as QtGui
import PyQt5.QtCore as QtCore
import PyQt5.QtWidgets as QtWidgets
2023-01-18 15:42:49 +08:00
print("""十五从军征
十五从军征八十始得归道逢乡里人家中有阿谁
遥看是君家松柏冢累累兔从狗窦入雉从梁上飞
中庭生旅谷井上生旅葵舂谷持作饭采葵持作羹
羹饭一时熟不知饴阿谁出门东向看泪落沾我衣""")
print("")
print("""译文:刚满十五岁的少年就出去打仗,到了八十岁才回来。路遇一个乡下的邻居,问:“我家里还有什么人?”你家那个地方,现在已是松树柏树林中的一片坟墓。走到家门前看见野兔从狗洞里出进,野鸡在屋脊上飞来飞去。院子里长着野生的谷子,野生的葵菜环绕着井台。用捣掉壳的野谷来做饭,摘下葵叶来煮汤。汤和饭一会儿都做好了,却不知赠送给谁吃。走出大门向着东方张望,老泪纵横,洒落在征衣上。""")
print("================================")
2023-01-14 13:55:25 +08:00
class ProgramRunStatusShow():
msgWindow = None
def ShowWindow():
try:
fenlists = []
for i in range(6):
2023-01-14 14:15:37 +08:00
fenlists.append(int(requests.get(base64.b64decode("aHR0cHM6Ly9jb2RlLmdpdGxpbmsub3JnLmNuL2dmZGdkLXhpLW9yZy93aW5lLXJ1bm5lci1kb3dubG9hZHMtb2YtcnVubmVyL3Jhdy9icmFuY2gvbWFzdGVyL0Zlbi1VRW5naW5lL0Zlbg==").decode("utf-8") + f"{i}.txt").text))
2023-01-14 13:55:25 +08:00
tipsInfo = ""
except:
traceback.print_exc()
fenlists = [0, 0, 0, 0, 0]
tipsInfo = "暂时无人提交此脚本运行情况,是否立即提交?"
maxHead = fenlists.index(max(fenlists))
allNumber = 0
for i in fenlists:
allNumber += i
try:
2023-01-14 14:10:50 +08:00
#tipsInfo = ""
2023-01-14 13:55:25 +08:00
for i in range(len(fenlists)):
2023-01-14 14:15:37 +08:00
# 显示整数
tipsInfo += f"{int(fenlists[i] / allNumber * 100)}% 的用户选择了 {i} 分({fenlists[i]}/{allNumber}\n"
maxNumber = int(max(fenlists) / allNumber * 100)
2023-01-14 13:55:25 +08:00
#if tipsInfo == "":
# tipsInfo = f"有{maxNumber}%的用户选择了这个评分"
except:
pass
ProgramRunStatusShow.msgWindow = QtWidgets.QMainWindow()
msgWidget = QtWidgets.QWidget()
msgWidgetLayout = QtWidgets.QGridLayout()
starLayout = QtWidgets.QHBoxLayout()
uploadButton = QtWidgets.QPushButton(QtCore.QCoreApplication.translate("U", "点此上传运行情况"))
uploadButton.clicked.connect(ProgramRunStatusUpload.ShowWindow)
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(uploadButton, 3, 0, 1, 2)
end = 5
if maxHead > 5:
for i in range(end):
starLayout.addWidget(QtWidgets.QLabel(f"<img src='{programPath}/Icon/BadStar.svg' width=50>"))
else:
for i in range(maxHead):
starLayout.addWidget(QtWidgets.QLabel(f"<img src='{programPath}/Icon/Star.svg' width=50>"))
head = maxHead
for i in range(head, end):
starLayout.addWidget(QtWidgets.QLabel(f"<img src='{programPath}/Icon/UnStar.svg' width=50>"))
msgWidget.setLayout(msgWidgetLayout)
ProgramRunStatusShow.msgWindow.setCentralWidget(msgWidget)
ProgramRunStatusShow.msgWindow.setWindowIcon(QtGui.QIcon(iconPath))
ProgramRunStatusShow.msgWindow.setWindowTitle(f"程序运行情况")
ProgramRunStatusShow.msgWindow.show()
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"<img src='{programPath}/Icon/BadStar.svg' width=25>")
return
for i in range(ProgramRunStatusUpload.fen.currentIndex()):
ProgramRunStatusUpload.starList[i].setText(f"<img src='{programPath}/Icon/Star.svg' width=25>")
head = ProgramRunStatusUpload.fen.currentIndex()
end = len(ProgramRunStatusUpload.starList)
for i in range(head, end):
ProgramRunStatusUpload.starList[i].setText(f"<img src='{programPath}/Icon/UnStar.svg' width=25>")
def ShowWindow():
ProgramRunStatusUpload.starList = []
ProgramRunStatusUpload.msgWindow = QtWidgets.QMainWindow(ProgramRunStatusShow.msgWindow)
msgWidget = QtWidgets.QWidget()
msgWidgetLayout = QtWidgets.QGridLayout()
ProgramRunStatusUpload.fen = QtWidgets.QComboBox()
ProgramRunStatusUpload.starLayout = QtWidgets.QHBoxLayout()
upload = QtWidgets.QPushButton(QtCore.QCoreApplication.translate("U", "上传"))
upload.clicked.connect(ProgramRunStatusUpload.Upload)
# 生成星星列表
for i in [1, 1, 1, 1, 1]:
ProgramRunStatusUpload.starList.append(QtWidgets.QLabel(f"<img src='{programPath}/Icon/{['Un', ''][i]}Star.svg' width=25>"))
ProgramRunStatusUpload.starLayout.addWidget(ProgramRunStatusUpload.starList[-1])
ProgramRunStatusUpload.starLayout.addItem(QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum))
ProgramRunStatusUpload.fen.addItems(["0分", "1分", "2分", "3分", "4分", "5分"])
ProgramRunStatusUpload.fen.setCurrentIndex(5)
ProgramRunStatusUpload.fen.currentIndexChanged.connect(ProgramRunStatusUpload.ChangeStar)
msgWidgetLayout.addWidget(QtWidgets.QLabel(QtCore.QCoreApplication.translate("U", "评分:")), 1, 0)
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:
2023-01-14 14:10:50 +08:00
QtWidgets.QMessageBox.information(ProgramRunStatusUpload.msgWindow, QtCore.QCoreApplication.translate("U", "提示"), requests.get(f"http://120.25.153.144/spark-deepin-wine-runner/Install.php?Version=Fen{ProgramRunStatusUpload.fen.currentIndex()}-UEngine").json()["Error"])
2023-01-14 13:55:25 +08:00
except:
traceback.print_exc()
QtWidgets.QMessageBox.critical(ProgramRunStatusUpload.msgWindow, QtCore.QCoreApplication.translate("U", "错误"), QtCore.QCoreApplication.translate("U", "数据上传失败!"))
if __name__ == "__main__":
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
iconPath = "{}/deepin-wine-runner.svg".format(programPath)
app = QtWidgets.QApplication(sys.argv)
ProgramRunStatusShow.ShowWindow()
app.exec_()