diff --git a/config.ini b/config.ini index 9067203..c477692 100644 --- a/config.ini +++ b/config.ini @@ -4,10 +4,10 @@ now_ip = 192.168.0.186 new_ip = 192.168.0.186 file_encoding = utf-8 dir = D:\LYserver\ -server_path = ${GAME:dir}server\ -web_path = ${GAME:dir}web\ -client_path = ${GAME:dir}client\ -tool_path = ${GAME:dir}tool\ +server_path = ${dir}server\ +web_path = ${dir}web\ +client_path = ${dir}client\ +tool_path = ${dir}tool\ [GAME_PATH] path01 = ${GAME:server_path}Common\AMServer\x64\AMServer64_R.exe @@ -42,16 +42,17 @@ path12 = ${GAME:web_path}args_ios.php path13 = ${GAME:web_path}api\notice.php [GAME_DATA_SQL] -sql1 = sql +game_ip = UPDATE `gameback`.`bg_server` SET `server_ip` = '${GAME:now_ip}' WHERE `id` IN (1,2) +game_name = UPDATE `gameback`.`bg_server` SET `name` = REPLACE(`name`,'${GAME:game_name}','${GAME:game_name}_new') WHERE `name` LIKE '%${GAME:game_name}%'; [WEB] domain_name = localhost web_port = 82 -gm_url = ${domain_name}:${web_port}/gm +gm_url = http://${domain_name}:${web_port}/gm gm_code = 123456 gm_user = test gm_pass = test -game_back = ${domain_name}:${web_port}/gameback +game_back = http://${domain_name}:${web_port}/gameback game_code = 123456 game_user = test game_pass = test @@ -92,15 +93,6 @@ heidisql_path = ${GAME:tool_path}HeidiSQL\heidisql.exe notepad3_path = ${GAME:tool_path}Notepad3\Notepad3.exe composer_path = ${GAME:tool_path}Composer\ -[SERVER_PATH] -php_path = ${GAME:tool_path}php\php5.6.9nts\ -php_spawner_path = ${GAME:tool_path}php-cgi-spawner\ -php_cgi_port = 9001 -nginx_path = ${GAME:tool_path}Nginx1.15.11\ -mysql_path = ${GAME:tool_path}MySQL5.7.26\ -game_path = ${GAME:server_path}Common\AMServer\x64\AMServer64_R.exe|${GAME:server_path}Common\LocalLogServer\x64\LocalLogServer64_R.exe|${GAME:server_path}Common\LoggerServer\x64\LoggerServer64_R.exe|${GAME:server_path}Common\SessionServer\x64\SessionServer64_R.exe|${GAME:server_path}Common\NameServer\x64\NameServer64_R.exe|${GAME:server_path}Common\BackStageServer\x64\BackStageServer64_R.exe,10|${GAME:server_path}Server\DBServer\x64\DBServer64_R.exe|${GAME:server_path}Server\GateServer\x64\GateServer64_R.exe|${GAME:server_path}Server\LogicServer\x64\LogicServerCQ64_R.exe|${GAME:server_path}Server2\DBServer\x64\DBServer64_R.exe|${GAME:server_path}Server2\GateServer\x64\GateServer64_R.exe|${GAME:server_path}Server2\LogicServer\x64\LogicServerCQ64_R.exe|${GAME:server_path}Server跨服\DBServer\x64\DBServer64_R.exe|${GAME:server_path}Server跨服\GateServer\x64\GateServer64_R.exe|${GAME:server_path}Server跨服\LogicServer\x64\LogicServerCQ64_R.exe -mod_file_path = ${GAME:dir}测试1.txt|${GAME:dir}测试2.txt|${CLIENT_PATH:android_path}assets\data\scripts\platform\platform_adapter.lua|${CLIENT_PATH:android_path}assets\data\scripts\platform\windows\platform_adapter.lua|${GAME:server_path}server\LogicServer\crossserver.txt|${GAME:server_path}server\DBServer\crossserver.txt|${GAME:server_path}server2\LogicServer\crossserver.txt|${GAME:server_path}server2\DBServer\crossserver.txt|${GAME:server_path}server跨服\LogicServer\crossserver.txt|${GAME:server_path}server跨服\DBServer\crossserver.txt|${GAME:web_path}args.php|${GAME:web_path}args_ios.php|${GAME:web_path}api\notice.php - [OTHER] about = shileiye email = shileiye@qq.com diff --git a/dist/config.ini b/dist/config.ini new file mode 100644 index 0000000..c477692 --- /dev/null +++ b/dist/config.ini @@ -0,0 +1,99 @@ +[GAME] +game_name = 幽冥传奇 +now_ip = 192.168.0.186 +new_ip = 192.168.0.186 +file_encoding = utf-8 +dir = D:\LYserver\ +server_path = ${dir}server\ +web_path = ${dir}web\ +client_path = ${dir}client\ +tool_path = ${dir}tool\ + +[GAME_PATH] +path01 = ${GAME:server_path}Common\AMServer\x64\AMServer64_R.exe +path02 = ${GAME:server_path}Common\LocalLogServer\x64\LocalLogServer64_R.exe +path03 = ${GAME:server_path}Common\LoggerServer\x64\LoggerServer64_R.exe +path04 = ${GAME:server_path}Common\SessionServer\x64\SessionServer64_R.exe +path05 = ${GAME:server_path}Common\NameServer\x64\NameServer64_R.exe +path06 = ${GAME:server_path}Common\BackStageServer\x64\BackStageServer64_R.exe,10 +path07 = ${GAME:server_path}Server\DBServer\x64\DBServer64_R.exe +path08 = ${GAME:server_path}Server\GateServer\x64\GateServer64_R.exe +path09 = ${GAME:server_path}Server\LogicServer\x64\LogicServerCQ64_R.exe +path10 = ${GAME:server_path}Server2\DBServer\x64\DBServer64_R.exe +path11 = ${GAME:server_path}Server2\GateServer\x64\GateServer64_R.exe +path12 = ${GAME:server_path}Server2\LogicServer\x64\LogicServerCQ64_R.exe +path13 = ${GAME:server_path}Server跨服\DBServer\x64\DBServer64_R.exe +path14 = ${GAME:server_path}Server跨服\GateServer\x64\GateServer64_R.exe +path15 = ${GAME:server_path}Server跨服\LogicServer\x64\LogicServerCQ64_R.exe + +[GAME_FILE_PATH] +path01 = ${GAME:dir}测试1.txt +path02 = ${GAME:dir}测试2.txt +path03 = ${ANDROID:android_name_file}assets\data\scripts\platform\platform_adapter.lua +path04 = ${ANDROID:android_name_file}assets\data\scripts\platform\windows\platform_adapter.lua +path05 = ${GAME:server_path}server\LogicServer\crossserver.txt +path06 = ${GAME:server_path}server\DBServer\crossserver.txt +path07 = ${GAME:server_path}server2\LogicServer\crossserver.txt +path08 = ${GAME:server_path}server2\DBServer\crossserver.txt +path09 = ${GAME:server_path}server跨服\LogicServer\crossserver.txt +path10 = ${GAME:server_path}server跨服\DBServer\crossserver.txt +path11 = ${GAME:web_path}args.php +path12 = ${GAME:web_path}args_ios.php +path13 = ${GAME:web_path}api\notice.php + +[GAME_DATA_SQL] +game_ip = UPDATE `gameback`.`bg_server` SET `server_ip` = '${GAME:now_ip}' WHERE `id` IN (1,2) +game_name = UPDATE `gameback`.`bg_server` SET `name` = REPLACE(`name`,'${GAME:game_name}','${GAME:game_name}_new') WHERE `name` LIKE '%${GAME:game_name}%'; + +[WEB] +domain_name = localhost +web_port = 82 +gm_url = http://${domain_name}:${web_port}/gm +gm_code = 123456 +gm_user = test +gm_pass = test +game_back = http://${domain_name}:${web_port}/gameback +game_code = 123456 +game_user = test +game_pass = test + +[NGINX] +nginx_path = ${GAME:tool_path}Nginx1.15.11\ + +[PHP] +php_path = ${GAME:tool_path}php\php5.6.9nts\ +php_spawner_path = ${GAME:tool_path}php-cgi-spawner\ +php_cgi_port = 9001 + +[MYSQL] +mysql_path = ${GAME:tool_path}MySQL5.7.26\ +mysql_host = 127.0.0.1 +mysql_port = 3306 +mysql_user = cq_dba +mysql_pass = 123456abc + +[ANDROID] +android_path = ${GAME:client_path}apk\ +android_name = ${android_path}game.apk +android_name_file = ${android_path}game\ +tmp_android_name = ${android_path}game_tmp.apk +new_android_name = ${android_path}game_signed.apk + +[pc] +pc_path = ${GAME:client_path}pc\ +pc_name = ${pc_path}pc\bin.exe + +[ios] +ios_path = ${GAME:client_path}ios\ +ios_name = ${android_path}game.ipa + +[TOOL_PATH] +apktool_path = ${GAME:tool_path}apktool\ +heidisql_path = ${GAME:tool_path}HeidiSQL\heidisql.exe +notepad3_path = ${GAME:tool_path}Notepad3\Notepad3.exe +composer_path = ${GAME:tool_path}Composer\ + +[OTHER] +about = shileiye +email = shileiye@qq.com + diff --git a/dist/main.exe b/dist/main.exe new file mode 100644 index 0000000..7b33d5b Binary files /dev/null and b/dist/main.exe differ diff --git a/main.py b/main.py index 673e753..2bdb743 100644 --- a/main.py +++ b/main.py @@ -10,6 +10,7 @@ import time from subprocess import Popen import sys +import pymysql from PyQt5.QtCore import pyqtSignal, QThread from PyQt5.QtGui import QTextCursor from PyQt5.QtWidgets import QApplication, QMainWindow, QMessageBox @@ -43,6 +44,8 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.newIpInput.setText(config['GAME']['new_ip']) self.nowGameLabel.setText(config['GAME']['game_name']) self.newGameInput.setText(config['GAME']['game_name']) + + # 设置按钮状态 if isinstance(checkprocess("nginx.exe"), int): self.nginxButton.setText("关闭Nginx") else: @@ -63,22 +66,47 @@ class MainWindow(QMainWindow, Ui_MainWindow): # print(key, values) # print(config.items("GAME_FILE_PATH")) # return - # for key, value in config.items('GAME_FILE_PATH'): - # print(key, value) - # return message = QMessageBox.information(self, "提示信息", "确定要保存设置吗?", QMessageBox.Ok | QMessageBox.No, QMessageBox.No) if message == QMessageBox.No: return + + # 取值 now_ip = config['GAME']['now_ip'] new_ip = self.newIpInput.text() now_game = config['GAME']['game_name'] new_game = self.newGameInput.text() compile_ip = re.compile('^(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|[1-9])\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)$') + # 验证IP地址格式 if (new_ip == "") or new_game == "" or not (compile_ip.match(new_ip)): QMessageBox.information(self, "提示信息", "IP地址、游戏名称为空或有误,请正确填写IPv4地址或游戏名称!") return - dirname = config['GAME_FILE_PATH'].items() + + # 处理SQL语句 + sql_game_ip = config['GAME_DATA_SQL']['game_ip'].replace(now_ip, new_ip) + sql_game_name = config['GAME_DATA_SQL']['game_name'].replace(now_game + '_new', new_game) + sqls = [sql_game_ip, sql_game_name] + + # 判断MYSQL是否启动 + if isinstance(checkprocess("mysqld.exe"), int): + mysql_run(sqls) + else: + message = QMessageBox.information(self, "提示信息", "MYSQL尚未启动,数据库相关脚本无法执行,是否现在启动MYSQL?", QMessageBox.Ok | QMessageBox.No, QMessageBox.Ok) + if message == QMessageBox.Ok: + self.mysql(self.mysqlButton) # 触发MYSQL启动按钮 + sum = 0 + # 以0.5秒的频次检测MYSQL是否启动,超过20次则超时 + while not isinstance(checkprocess("mysqld.exe"), int): + if sum > 20: + QMessageBox.information(self, "提示信息", "MYSQL启动失败,请重新尝试!") + return + time.sleep(0.5) + sum = sum + 1 + mysql_run(sqls) + else: + return + + # 配置文件处理 sum = 0 for key, value in config.items('GAME_FILE_PATH'): print(key, value) @@ -111,14 +139,14 @@ class MainWindow(QMainWindow, Ui_MainWindow): saveconfig = open(configFile, 'wt', encoding=config['GAME']['file_encoding']) config.write(saveconfig) # 把要修改的节点的内容写到文件中 saveconfig.close() - # 设置界面显示 + + # 设置按钮文字变化 self.nowGameLabel.setText(new_game) self.nowIpLabel.setText(new_ip) + # 成功提示 QMessageBox.information(self, "提示信息", "配置保存成功!重启游戏后生效!
游戏名称:" + new_game + "----游戏IP:" + new_ip + "
共配置了" + str(sum) + "个文件") print('修改完成:' + new_game + ':' + new_ip) - return - # TODO 待完成数据库配置修改 def nginx(self, event): if self.nginxButton.text() == '启动Nginx': @@ -174,34 +202,47 @@ class MainWindow(QMainWindow, Ui_MainWindow): def game(self, event): if self.gameButton.text() == '启动游戏': - # TODO 更改配置文件格式 - game_path = config['GAME_PATH']['game_path'].split("|") - # 遍历字典列表 - for f in game_path: - print(f) - # 执行文本替换 - if len(f.split(",")) < 2: + # 读取游戏启动路径 + for key, value in config.items('GAME_PATH'): + print(key, value) + # 处理启动时间 + if len(value.split(",")) < 2: sleeptime = 0 else: - sleeptime = float(f.split(",")[1]) - game_file = f.split(",")[0] + sleeptime = float(value.split(",")[1]) + game_file = value.split(",")[0] try: Popen('start ' + game_file, shell=True, # cwd=values, # encoding='utf-8' ) - time.sleep(float(sleeptime)) # 延迟时间 + time.sleep(float(sleeptime)) # 延迟启动时间 except: QMessageBox.information(self, "提示信息", "启动“" + game_file + "”出错,可能文件不存在或配置不对!") return self.gameButton.setText("关闭游戏") else: - Popen( - 'taskkill /f /t /im LocalLogServer64_R.exe & taskkill /f /t /im LoggerServer64_R.exe & taskkill /f /t /im SessionServer64_R.exe & taskkill /f /t /im NameServer64_R.exe & taskkill /f /t /im LogicServerCQ64_R.exe & taskkill /f /t /im GateServer64_R.exe & taskkill /f /t /im DBCenterServer64_R.exe & taskkill /f /t /im DBServer64_R.exe & taskkill /f /t /im BackStageServer64_R.exe & taskkill /f /t /im AMServer64_R.exe', - shell=True, - # encoding='utf-8' - ) + # 读取游戏启动路径 + for key, value in config.items('GAME_PATH'): + print(key, value) + # 获取进程名称并结束进程 + game_file = value.split(",")[0].split("\\") + game_file = game_file[len(game_file) - 1] + try: + Popen( + 'taskkill /f /t /im ' + game_file, + shell=True, + # encoding='utf-8' + ) + except: + QMessageBox.information(self, "提示信息", "关闭游戏进程:“" + game_file + "”出错!") + return + # Popen( + # 'taskkill /f /t /im LocalLogServer64_R.exe & taskkill /f /t /im LoggerServer64_R.exe & taskkill /f /t /im SessionServer64_R.exe & taskkill /f /t /im NameServer64_R.exe & taskkill /f /t /im LogicServerCQ64_R.exe & taskkill /f /t /im GateServer64_R.exe & taskkill /f /t /im DBCenterServer64_R.exe & taskkill /f /t /im DBServer64_R.exe & taskkill /f /t /im BackStageServer64_R.exe & taskkill /f /t /im AMServer64_R.exe', + # shell=True, + # # encoding='utf-8' + # ) self.gameButton.setText("启动游戏") print('启动游戏,按钮被单击') @@ -238,6 +279,25 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.add_cmd_msg(cmd, cwd, title, obj, path, code) print('APK签名,按钮被单击') + def heidisql(self, event): + cmd = 'start "" ' + config['TOOL_PATH']['heidisql_path'] + Popen(cmd, + shell=True, + # cwd=config['MYSQL']['mysql_path'] + 'bin', + # encoding='utf-8' + ) + print('heidisql,按钮被单击') + + def gmurl(self, event): + cmd = 'start ' + config['WEB']['gm_url'] + Popen(cmd, + shell=True, + # cwd=config['MYSQL']['mysql_path'] + 'bin', + # encoding='utf-8' + ) + print('gmurl,按钮被单击') + #TODO 增加自动登录GM后台功能 + # 利用新线程进行脚本执行回显 def add_cmd_msg(self, cmd, cwd="", title="", obj="", path="", code="utf8"): obj.setEnabled(False) @@ -291,6 +351,34 @@ class Thread(QThread): startfile(self.path) +# MYSQL操作函数 +def mysql_run(sqls, table=""): + print(sqls) + # 打开数据库连接 + db = pymysql.connect(host=config['MYSQL']['mysql_host'], + user=config['MYSQL']['mysql_user'], + password=config['MYSQL']['mysql_pass'], + database=table, + port=int(config['MYSQL']['mysql_port']) + ) + # 使用cursor()方法获取操作游标 + cursor = db.cursor() + for sql in sqls: + try: + # 执行SQL语句 + cursor.execute(sql) + # 提交到数据库执行 + db.commit() + print('更新成功') + except: + print('出错了') + # 发生错误时回滚 + db.rollback() + # 关闭数据库连接 + db.close() + print('MySql执行完毕') + + # 进程判断,返回进程ID def checkprocess(processname): pl = psutil.pids() @@ -299,7 +387,7 @@ def checkprocess(processname): return pid -# 打开文件或文件夹 +# 打开文件或文件夹,并且选中文件 def startfile(filename): try: os.startfile(f'explorer /select, "{pathlib.Path(filename)}') diff --git a/main.spec b/main.spec new file mode 100644 index 0000000..b16def4 --- /dev/null +++ b/main.spec @@ -0,0 +1,40 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis(['main.py'], + pathex=['D:\\soft\\Python\\Python39\\Lib\\site-packages', 'D:\\soft\\Python\\Python39\\Lib', 'D:\\soft\\Python\\Python39\\Lib\\site-packages\\PyQt5\\Qt\\bin', 'D:\\Code\\python\\onekey\\venv\\Lib\\site-packages', ''], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) + +exe = EXE(pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='main', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=False, + disable_windowed_traceback=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None ) diff --git a/mainui.py b/mainui.py index 1635523..ce07234 100644 --- a/mainui.py +++ b/mainui.py @@ -16,6 +16,9 @@ class Ui_MainWindow(object): MainWindow.setObjectName("MainWindow") MainWindow.resize(560, 530) MainWindow.setMouseTracking(False) + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap(":/icon/src/icon/dengdai.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + MainWindow.setWindowIcon(icon) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.groupBox = QtWidgets.QGroupBox(self.centralwidget) @@ -81,6 +84,12 @@ class Ui_MainWindow(object): self.qianmingButton = QtWidgets.QPushButton(self.groupBox_3) self.qianmingButton.setGeometry(QtCore.QRect(190, 20, 80, 45)) self.qianmingButton.setObjectName("qianmingButton") + self.heidisqlButton = QtWidgets.QPushButton(self.groupBox_3) + self.heidisqlButton.setGeometry(QtCore.QRect(280, 20, 80, 45)) + self.heidisqlButton.setObjectName("heidisqlButton") + self.gmurlButton = QtWidgets.QPushButton(self.groupBox_3) + self.gmurlButton.setGeometry(QtCore.QRect(370, 20, 80, 45)) + self.gmurlButton.setObjectName("gmurlButton") self.CMDtextEdit = QtWidgets.QTextEdit(self.centralwidget) self.CMDtextEdit.setGeometry(QtCore.QRect(20, 320, 521, 180)) self.CMDtextEdit.setStyleSheet("background-color: rgb(0, 0, 0);\n" @@ -99,13 +108,15 @@ class Ui_MainWindow(object): self.mysqlButton.clicked.connect(MainWindow.mysql) self.gameButton.clicked.connect(MainWindow.game) self.fanbianyiButton.clicked.connect(MainWindow.fanbianyi) + self.heidisqlButton.clicked.connect(MainWindow.heidisql) + self.newIpInput.returnPressed.connect(self.saveSetButton.click) + self.newGameInput.returnPressed.connect(self.saveSetButton.click) + self.gmurlButton.clicked.connect(MainWindow.gmurl) QtCore.QMetaObject.connectSlotsByName(MainWindow) - - def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate - MainWindow.setWindowTitle(_translate("MainWindow", "通用游戏部署工具 v1.0 By:shileiye")) + MainWindow.setWindowTitle(_translate("MainWindow", "牛叉游戏部署工具 v1.0 By:shileiye")) self.groupBox.setTitle(_translate("MainWindow", "基本设置")) self.saveSetButton.setText(_translate("MainWindow", "保存")) self.newGameInput.setPlaceholderText(_translate("MainWindow", "输入新名称")) @@ -124,6 +135,8 @@ class Ui_MainWindow(object): self.fanbianyiButton.setText(_translate("MainWindow", "反编译APK")) self.shengchengButton.setText(_translate("MainWindow", "生成APK")) self.qianmingButton.setText(_translate("MainWindow", "APK签名")) + self.heidisqlButton.setText(_translate("MainWindow", "HeidiSQL")) + self.gmurlButton.setText(_translate("MainWindow", "GM后台")) self.CMDtextEdit.setHtml(_translate("MainWindow", "\n" "