修改了Gunicorn标签内容
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import json
|
||||
from loguru import logger
|
||||
from PySide6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit,
|
||||
QPushButton, QComboBox, QMessageBox, QTextEdit,
|
||||
@@ -6,7 +7,7 @@ from PySide6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineE
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
from threads import (GitInstallThread, GitCloneThread, ListDirectoryThread,
|
||||
DeleteDirectoryThread, SetTimezoneAndRestartThread,
|
||||
SetTimezoneAndRestartThread,
|
||||
CheckFirewallThread, OpenPortThread)
|
||||
|
||||
|
||||
@@ -33,11 +34,6 @@ class RemoteCommandTab(QWidget):
|
||||
self.project_path_input.setPlaceholderText("/home/user/project")
|
||||
git_layout.addWidget(self.project_path_input, 1, 1)
|
||||
|
||||
git_layout.addWidget(QLabel("删除目录:"), 2, 0)
|
||||
self.delete_dir_input = QLineEdit()
|
||||
self.delete_dir_input.setPlaceholderText("/home/user/old_project")
|
||||
git_layout.addWidget(self.delete_dir_input, 2, 1)
|
||||
|
||||
self.install_git_btn = QPushButton("安装Git")
|
||||
self.install_git_btn.clicked.connect(self.install_git)
|
||||
git_layout.addWidget(self.install_git_btn, 0, 2)
|
||||
@@ -50,10 +46,6 @@ class RemoteCommandTab(QWidget):
|
||||
self.list_dir_btn.clicked.connect(self.list_directory)
|
||||
git_layout.addWidget(self.list_dir_btn, 2, 2)
|
||||
|
||||
self.delete_dir_btn = QPushButton("删除目录")
|
||||
self.delete_dir_btn.clicked.connect(self.delete_directory)
|
||||
git_layout.addWidget(self.delete_dir_btn, 3, 2)
|
||||
|
||||
self.set_timezone_btn = QPushButton("设置时区并重启")
|
||||
self.set_timezone_btn.clicked.connect(self.set_timezone_and_restart)
|
||||
git_layout.addWidget(self.set_timezone_btn, 3, 0, 1, 2)
|
||||
@@ -80,17 +72,6 @@ class RemoteCommandTab(QWidget):
|
||||
firewall_group.setLayout(firewall_layout)
|
||||
layout.addWidget(firewall_group)
|
||||
|
||||
# Settings.py编辑器
|
||||
settings_group = QGroupBox("Settings.py编辑器")
|
||||
settings_layout = QVBoxLayout()
|
||||
|
||||
self.settings_editor = QTextEdit()
|
||||
self.settings_editor.setPlaceholderText("settings.py内容将在这里显示...")
|
||||
settings_layout.addWidget(self.settings_editor)
|
||||
|
||||
settings_group.setLayout(settings_layout)
|
||||
layout.addWidget(settings_group)
|
||||
|
||||
# 操作输出
|
||||
output_group = QGroupBox("操作输出")
|
||||
output_layout = QVBoxLayout()
|
||||
@@ -106,15 +87,31 @@ class RemoteCommandTab(QWidget):
|
||||
layout.addStretch()
|
||||
self.setLayout(layout)
|
||||
|
||||
# 加载Git配置
|
||||
# 从配置文件加载git配置
|
||||
self.load_git_config()
|
||||
|
||||
def load_git_config(self):
|
||||
if self.parent and hasattr(self.parent, 'server_connection_tab'):
|
||||
git_url = self.parent.server_connection_tab.git_url_input.text()
|
||||
remote_dir = self.parent.server_connection_tab.remote_dir_input.text()
|
||||
self.git_url_input.setText(git_url)
|
||||
self.project_path_input.setText(remote_dir)
|
||||
try:
|
||||
# 从config.json文件读取配置
|
||||
config_path = os.path.join(os.path.dirname(__file__), 'config.json')
|
||||
with open(config_path, 'r', encoding='utf-8') as f:
|
||||
config = json.load(f)
|
||||
|
||||
# 获取第一个服务器的配置
|
||||
if config and 'servers' in config and len(config['servers']) > 0:
|
||||
server_config = config['servers'][0]
|
||||
git_url = server_config.get('git_url', '')
|
||||
project_path = server_config.get('remote_directory', '')
|
||||
|
||||
self.git_url_input.setText(git_url)
|
||||
self.project_path_input.setText(project_path)
|
||||
|
||||
logger.info(f"从配置文件加载git配置: git_url={git_url}, project_path={project_path}")
|
||||
else:
|
||||
logger.warning("配置文件中未找到服务器配置")
|
||||
except Exception as e:
|
||||
logger.error(f"加载git配置失败: {str(e)}")
|
||||
QMessageBox.warning(self, "警告", f"加载git配置失败: {str(e)}")
|
||||
|
||||
def install_git(self):
|
||||
if not self.check_ssh_connection():
|
||||
@@ -147,6 +144,22 @@ class RemoteCommandTab(QWidget):
|
||||
QMessageBox.warning(self, "警告", "请填写Git仓库URL和项目路径")
|
||||
return
|
||||
|
||||
# 从config.json获取django_path作为克隆目标路径
|
||||
try:
|
||||
config_path = os.path.join(os.path.dirname(__file__), 'config.json')
|
||||
with open(config_path, 'r', encoding='utf-8') as f:
|
||||
config = json.load(f)
|
||||
|
||||
if config and 'servers' in config and len(config['servers']) > 0:
|
||||
server_config = config['servers'][0]
|
||||
django_path = server_config.get('django_path', '')
|
||||
|
||||
if django_path:
|
||||
project_path = django_path
|
||||
logger.info(f"使用django_path作为克隆目标路径: {django_path}")
|
||||
except Exception as e:
|
||||
logger.error(f"获取django_path失败: {str(e)}")
|
||||
|
||||
self.output_text.append(f"正在克隆 {git_url} 到 {project_path}...")
|
||||
self.clone_btn.setEnabled(False)
|
||||
|
||||
@@ -183,42 +196,11 @@ class RemoteCommandTab(QWidget):
|
||||
self.list_dir_btn.setEnabled(True)
|
||||
if success:
|
||||
self.output_text.append(f"目录列表:\n{message}")
|
||||
logger.info(f"目录列表成功")
|
||||
logger.info(f"目录列表成功:\n{message}")
|
||||
else:
|
||||
self.output_text.append(f"列出目录失败: {message}")
|
||||
logger.error(f"列出目录失败: {message}")
|
||||
|
||||
def delete_directory(self):
|
||||
if not self.check_ssh_connection():
|
||||
return
|
||||
|
||||
path = self.delete_dir_input.text().strip()
|
||||
if not path:
|
||||
QMessageBox.warning(self, "警告", "请输入要删除的目录路径")
|
||||
return
|
||||
|
||||
reply = QMessageBox.question(self, "确认删除",
|
||||
f"确定要删除目录 {path} 吗?此操作不可撤销!",
|
||||
QMessageBox.Yes | QMessageBox.No)
|
||||
if reply == QMessageBox.No:
|
||||
return
|
||||
|
||||
self.output_text.append(f"正在删除目录 {path}...")
|
||||
self.delete_dir_btn.setEnabled(False)
|
||||
|
||||
self.delete_dir_thread = DeleteDirectoryThread(self.parent.ssh_client, path)
|
||||
self.delete_dir_thread.result_ready.connect(self.on_delete_directory_result)
|
||||
self.delete_dir_thread.start()
|
||||
|
||||
def on_delete_directory_result(self, success, message):
|
||||
self.delete_dir_btn.setEnabled(True)
|
||||
if success:
|
||||
self.output_text.append(f"目录删除成功: {message}")
|
||||
logger.info(f"目录删除成功: {message}")
|
||||
else:
|
||||
self.output_text.append(f"目录删除失败: {message}")
|
||||
logger.error(f"目录删除失败: {message}")
|
||||
|
||||
def set_timezone_and_restart(self):
|
||||
if not self.check_ssh_connection():
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user