增加Apache配置,当有Apache配置时显示Apache服务按钮
This commit is contained in:
parent
b26411eec7
commit
f638a47436
BIN
dist/main.exe
vendored
BIN
dist/main.exe
vendored
Binary file not shown.
46
main.py
46
main.py
@ -45,13 +45,16 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.newGameInput.setText(config['GAME']['game_name'])
|
||||
|
||||
# 设置按钮状态
|
||||
if not config.has_section('NGINX'):
|
||||
if not config.has_section('NGINX') and not config.has_section('APACHE'):
|
||||
self.nginxButton.setDisabled(True)
|
||||
else:
|
||||
if isinstance(checkprocess("nginx.exe"), int):
|
||||
self.nginxButton.setText("关闭Nginx")
|
||||
elif config.has_section('APACHE'):
|
||||
self.nginxButton.setText("启动Apache")
|
||||
if isinstance(checkprocess("httpd.exe"), int):
|
||||
self.nginxButton.setText("关闭Apache")
|
||||
else:
|
||||
self.nginxButton.setText("启动Nginx")
|
||||
if isinstance(checkprocess("nginx.exe"), int):
|
||||
self.nginxButton.setText("关闭Nginx")
|
||||
|
||||
if not config.has_section('MYSQL'):
|
||||
self.mysqlButton.setDisabled(True)
|
||||
@ -186,21 +189,40 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
# encoding='utf-8'
|
||||
)
|
||||
self.nginxButton.setText("关闭Nginx")
|
||||
else:
|
||||
nginx_process = Popen('.\\nginx.exe -s stop',
|
||||
elif self.nginxButton.text() == '关闭Nginx':
|
||||
Popen('.\\nginx.exe -s stop',
|
||||
shell=True,
|
||||
cwd=config['NGINX']['nginx_path'],
|
||||
# encoding='utf-8'
|
||||
)
|
||||
spawner_process = Popen('taskkill /f /t /im php-cgi-spawner.exe',
|
||||
Popen('taskkill /f /t /im php-cgi-spawner.exe',
|
||||
shell=True,
|
||||
# encoding='utf-8'
|
||||
)
|
||||
PHP_process = Popen('taskkill /f /t /im php-cgi.exe',
|
||||
Popen('taskkill /f /t /im php-cgi.exe',
|
||||
shell=True,
|
||||
# encoding='utf-8'
|
||||
)
|
||||
self.nginxButton.setText("启动Nginx")
|
||||
elif self.nginxButton.text() == '启动Apache':
|
||||
Popen('.\\httpd.exe',
|
||||
shell=True,
|
||||
cwd=config['APACHE']['apache_path'] + 'bin\\',
|
||||
# encoding='utf-8'
|
||||
)
|
||||
self.nginxButton.setText("关闭Apache")
|
||||
elif self.nginxButton.text() == '关闭Apache':
|
||||
Popen('.\\httpd.exe –k stop',
|
||||
shell=True,
|
||||
cwd=config['APACHE']['apache_path'] + 'bin\\',
|
||||
# encoding='utf-8'
|
||||
)
|
||||
Popen('taskkill /f /t /im httpd.exe',
|
||||
shell=True,
|
||||
# encoding='utf-8'
|
||||
)
|
||||
self.nginxButton.setText("启动Apache")
|
||||
|
||||
# print(process)
|
||||
# os.chdir("D:\\LYserver\\phpstudy_pro\\Extensions\\Nginx1.15.11")
|
||||
# nginxtype = os.system('start .\\nginx.exe') # 不弹出界面
|
||||
@ -210,7 +232,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
|
||||
def mysql(self, event):
|
||||
if self.mysqlButton.text() == '启动MySql':
|
||||
Popen('.\\mysqld.exe',
|
||||
Popen('.\\mysqld.exe --console',
|
||||
shell=True,
|
||||
cwd=config['MYSQL']['mysql_path'] + 'bin',
|
||||
# encoding='utf-8'
|
||||
@ -235,10 +257,14 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
else:
|
||||
sleeptime = float(value.split(",")[1])
|
||||
game_file = value.split(",")[0]
|
||||
# 处理启动路径
|
||||
game_path = '\\'.join(value.split("\\")[0:-1])
|
||||
# print(game_path)
|
||||
|
||||
try:
|
||||
Popen('start ' + game_file,
|
||||
shell=True,
|
||||
# cwd=values,
|
||||
cwd=game_path,
|
||||
# encoding='utf-8'
|
||||
)
|
||||
time.sleep(float(sleeptime)) # 延迟启动时间
|
||||
|
Loading…
x
Reference in New Issue
Block a user