优化配置文件结构
This commit is contained in:
parent
4367aadad4
commit
2415730c0a
117
config.ini
117
config.ini
@ -1,34 +1,105 @@
|
||||
[DEFAULT]
|
||||
dir = D:\LYserver\
|
||||
file_encoding = utf-8
|
||||
|
||||
[GAME_SET]
|
||||
[GAME]
|
||||
game_name = 幽冥传奇
|
||||
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]
|
||||
php_path = ${dir}tool\php\php5.6.9nts\
|
||||
php_spawner_path = ${dir}tool\php-cgi-spawner\
|
||||
[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]
|
||||
sql1 = sql
|
||||
|
||||
[WEB]
|
||||
domain_name = localhost
|
||||
web_port = 82
|
||||
gm_url = ${domain_name}:${web_port}/gm
|
||||
gm_code = 123456
|
||||
gm_user = test
|
||||
gm_pass = test
|
||||
game_back = ${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
|
||||
nginx_path = ${dir}tool\Nginx1.15.11\
|
||||
mysql_path = ${dir}tool\MySQL5.7.26\
|
||||
game_path = ${dir}server\Common\AMServer\x64\AMServer64_R.exe|${dir}server\Common\LocalLogServer\x64\LocalLogServer64_R.exe|${dir}server\Common\LoggerServer\x64\LoggerServer64_R.exe|${dir}server\Common\SessionServer\x64\SessionServer64_R.exe|${dir}server\Common\NameServer\x64\NameServer64_R.exe|${dir}server\Common\BackStageServer\x64\BackStageServer64_R.exe,10|${dir}server\Server\DBServer\x64\DBServer64_R.exe|${dir}server\Server\GateServer\x64\GateServer64_R.exe|${dir}server\Server\LogicServer\x64\LogicServerCQ64_R.exe|${dir}server\Server2\DBServer\x64\DBServer64_R.exe|${dir}server\Server2\GateServer\x64\GateServer64_R.exe|${dir}server\Server2\LogicServer\x64\LogicServerCQ64_R.exe|${dir}server\Server跨服\DBServer\x64\DBServer64_R.exe|${dir}server\Server跨服\GateServer\x64\GateServer64_R.exe|${dir}server\Server跨服\LogicServer\x64\LogicServerCQ64_R.exe
|
||||
mod_file_path = ${dir}测试1.txt|${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|${dir}server\server\LogicServer\crossserver.txt|${dir}server\server\DBServer\crossserver.txt|${dir}server\server2\LogicServer\crossserver.txt|${dir}server\server2\DBServer\crossserver.txt|${dir}server\server跨服\LogicServer\crossserver.txt|${dir}server\server跨服\DBServer\crossserver.txt|${dir}web\args.php|${dir}web\args_ios.php|${dir}web\api\notice.php
|
||||
|
||||
[CLIENT_PATH]
|
||||
client_path = ${dir}client\
|
||||
android_name = game.apk
|
||||
android_path = ${client_path}game\
|
||||
tmp_android_name = game_tmp.apk
|
||||
new_android_name = game_signed.apk
|
||||
pc_path = ${client_path}pc\
|
||||
[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 = ${dir}tool\apktool\
|
||||
heidisql_path = ${dir}tool\HeidiSQL\heidisql.exe
|
||||
notepad3_path = ${dir}tool\Notepad3\Notepad3.exe
|
||||
composer_path = ${dir}tool\Composer\
|
||||
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\
|
||||
|
||||
[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
|
||||
|
77
main.py
77
main.py
@ -33,57 +33,65 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.setupUi(self)
|
||||
|
||||
self.apktool_path = config['TOOL_PATH']['apktool_path']
|
||||
self.android_name = config['CLIENT_PATH']['client_path'] + config['CLIENT_PATH']['android_name']
|
||||
self.android_path = config['CLIENT_PATH']['android_path']
|
||||
self.tmp_android_name = config['CLIENT_PATH']['client_path'] + config['CLIENT_PATH']['tmp_android_name']
|
||||
self.new_android_name = config['CLIENT_PATH']['client_path'] + config['CLIENT_PATH']['new_android_name']
|
||||
self.android_name = config['ANDROID']['android_name']
|
||||
self.android_name_file = config['ANDROID']['android_name_file']
|
||||
self.tmp_android_name = config['ANDROID']['tmp_android_name']
|
||||
self.new_android_name = config['ANDROID']['new_android_name']
|
||||
|
||||
# 初始赋值
|
||||
self.nowIpLabel.setText(config['GAME_SET']['now_ip'])
|
||||
self.newIpInput.setText(config['GAME_SET']['new_ip'])
|
||||
self.nowGameLabel.setText(config['GAME_SET']['game_name'])
|
||||
self.newGameInput.setText(config['GAME_SET']['game_name'])
|
||||
self.nowIpLabel.setText(config['GAME']['now_ip'])
|
||||
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:
|
||||
self.nginxButton.setText("启动Nginx")
|
||||
|
||||
if isinstance(checkprocess("mysqld.exe"), int):
|
||||
self.mysqlButton.setText("关闭MySql")
|
||||
else:
|
||||
self.mysqlButton.setText("启动MySql")
|
||||
|
||||
def saveSet(self, event):
|
||||
print('保存设置,按钮被单击')
|
||||
# print(config['GAME_PATH']['game'])
|
||||
# print(config['GAME_FILE_PATH']['game'])
|
||||
# tinydict = ast.literal_eval(config['GAME_PATH']['game'])
|
||||
# print("字典值 : %s" %tinydict.items())
|
||||
# # 遍历字典列表
|
||||
# for key, values in tinydict.items():
|
||||
# print(key, values)
|
||||
# for key, value in config['GAME_PATH'].items():
|
||||
# print(config.items("GAME_FILE_PATH"))
|
||||
# return
|
||||
# for key, value in config.items('GAME_FILE_PATH'):
|
||||
# print(key, value)
|
||||
# print(config.options('GAME_PATH'))
|
||||
# return
|
||||
message = QMessageBox.information(self, "提示信息", "确定要保存设置吗?", QMessageBox.Ok | QMessageBox.No, QMessageBox.No)
|
||||
if message == QMessageBox.No:
|
||||
return
|
||||
now_ip = config['GAME_SET']['now_ip']
|
||||
now_ip = config['GAME']['now_ip']
|
||||
new_ip = self.newIpInput.text()
|
||||
now_game = config['GAME_SET']['game_name']
|
||||
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['SERVER_PATH']['mod_file_path']
|
||||
dirname = config['GAME_FILE_PATH'].items()
|
||||
sum = 0
|
||||
for filedir in dirname.split("|"):
|
||||
# 执行文本替换
|
||||
if len(filedir.split(",")) < 2:
|
||||
isencoding = config['DEFAULT']['file_encoding']
|
||||
for key, value in config.items('GAME_FILE_PATH'):
|
||||
print(key, value)
|
||||
# 处理文件编码
|
||||
if len(value.split(",")) < 2:
|
||||
code = config['GAME']['file_encoding']
|
||||
else:
|
||||
isencoding = filedir.split(",")[1]
|
||||
filename = filedir.split(",")[0]
|
||||
code = value.split(",")[1]
|
||||
filename = value.split(",")[0]
|
||||
|
||||
# 执行文件内容替换
|
||||
try:
|
||||
with open(filename, 'rt+', encoding=isencoding) as f:
|
||||
with open(filename, 'rt+', encoding=code) as f:
|
||||
t = f.read()
|
||||
t = t.replace(now_ip, new_ip)
|
||||
t = t.replace(now_game, new_game)
|
||||
@ -97,10 +105,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
QMessageBox.information(self, "提示信息", "替换“" + filename + "”出错,可能文件不存在或编码不对,请检查需要替换的文件编码与配置文件编码是否相符!")
|
||||
return
|
||||
# 写入配置文件
|
||||
config.set('GAME_SET', 'game_name', new_game)
|
||||
config.set('GAME_SET', 'now_ip', new_ip)
|
||||
config.set('GAME_SET', 'new_ip', new_ip)
|
||||
saveconfig = open(configFile, 'wt', encoding=config['DEFAULT']['file_encoding'])
|
||||
config.set('GAME', 'game_name', new_game)
|
||||
config.set('GAME', 'now_ip', new_ip)
|
||||
config.set('GAME', 'new_ip', new_ip)
|
||||
saveconfig = open(configFile, 'wt', encoding=config['GAME']['file_encoding'])
|
||||
config.write(saveconfig) # 把要修改的节点的内容写到文件中
|
||||
saveconfig.close()
|
||||
# 设置界面显示
|
||||
@ -116,20 +124,20 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
if self.nginxButton.text() == '启动Nginx':
|
||||
Popen('start .\\nginx.exe',
|
||||
shell=True,
|
||||
cwd=config['SERVER_PATH']['nginx_path'],
|
||||
cwd=config['NGINX']['nginx_path'],
|
||||
# encoding='utf-8'
|
||||
)
|
||||
Popen(
|
||||
config['SERVER_PATH']['php_spawner_path'] + 'php-cgi-spawner.exe "' + config['SERVER_PATH']['php_path'] + 'php-cgi.exe -c ' + config['SERVER_PATH']['php_path'] + 'php.ini" ' + config['SERVER_PATH']['php_cgi_port'] + ' 1+16',
|
||||
config['PHP']['php_spawner_path'] + 'php-cgi-spawner.exe "' + config['PHP']['php_path'] + 'php-cgi.exe -c ' + config['PHP']['php_path'] + 'php.ini" ' + config['PHP']['php_cgi_port'] + ' 1+16',
|
||||
shell=True,
|
||||
# cwd=config['DEFAULT']['dir'] + 'phpstudy_pro',
|
||||
# cwd=config['GAME']['dir'] + 'phpstudy_pro',
|
||||
# encoding='utf-8'
|
||||
)
|
||||
self.nginxButton.setText("关闭Nginx")
|
||||
else:
|
||||
nginx_process = Popen('.\\nginx.exe -s stop',
|
||||
shell=True,
|
||||
cwd=config['SERVER_PATH']['nginx_path'],
|
||||
cwd=config['NGINX']['nginx_path'],
|
||||
# encoding='utf-8'
|
||||
)
|
||||
spawner_process = Popen('taskkill /f /t /im php-cgi-spawner.exe',
|
||||
@ -152,7 +160,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
if self.mysqlButton.text() == '启动MySql':
|
||||
Popen('.\\mysqld.exe',
|
||||
shell=True,
|
||||
cwd=config['SERVER_PATH']['mysql_path'] + 'bin',
|
||||
cwd=config['MYSQL']['mysql_path'] + 'bin',
|
||||
# encoding='utf-8'
|
||||
)
|
||||
self.mysqlButton.setText("关闭MySql")
|
||||
@ -166,7 +174,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
|
||||
def game(self, event):
|
||||
if self.gameButton.text() == '启动游戏':
|
||||
game_path = config['SERVER_PATH']['game_path'].split("|")
|
||||
# TODO 更改配置文件格式
|
||||
game_path = config['GAME_PATH']['game_path'].split("|")
|
||||
# 遍历字典列表
|
||||
for f in game_path:
|
||||
print(f)
|
||||
@ -200,10 +209,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
obj = self.fanbianyiButton
|
||||
# obj.setText('运行中')
|
||||
title = obj.text()
|
||||
cmd = 'apktool d ' + self.android_name + ' -f -o ' + self.android_path
|
||||
cmd = 'apktool d ' + self.android_name + ' -f -o ' + self.android_name_file
|
||||
cwd = self.apktool_path
|
||||
code = "gbk"
|
||||
path = self.android_path
|
||||
path = self.android_name_file
|
||||
self.add_cmd_msg(cmd, cwd, title, obj, path, code)
|
||||
print('反编译APK,按钮被单击')
|
||||
|
||||
@ -211,7 +220,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
obj = self.shengchengButton
|
||||
# obj.setText('运行中')
|
||||
title = obj.text()
|
||||
cmd = 'apktool b ' + self.android_path + ' -o ' + self.tmp_android_name
|
||||
cmd = 'apktool b ' + self.android_name_file + ' -o ' + self.tmp_android_name
|
||||
cwd = self.apktool_path
|
||||
code = "gbk"
|
||||
path = self.tmp_android_name
|
||||
|
Loading…
x
Reference in New Issue
Block a user