diff --git a/dist/main.exe b/dist/main.exe index bfe22ab..8db32cc 100644 Binary files a/dist/main.exe and b/dist/main.exe differ diff --git a/main.py b/main.py index 43ec597..a186b57 100644 --- a/main.py +++ b/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) + 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") - else: - 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', - shell=True, - cwd=config['NGINX']['nginx_path'], - # encoding='utf-8' - ) - spawner_process = Popen('taskkill /f /t /im php-cgi-spawner.exe', - shell=True, - # encoding='utf-8' - ) - PHP_process = Popen('taskkill /f /t /im php-cgi.exe', - shell=True, - # encoding='utf-8' - ) + elif self.nginxButton.text() == '关闭Nginx': + Popen('.\\nginx.exe -s stop', + shell=True, + cwd=config['NGINX']['nginx_path'], + # encoding='utf-8' + ) + Popen('taskkill /f /t /im php-cgi-spawner.exe', + shell=True, + # encoding='utf-8' + ) + 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)) # 延迟启动时间