66
77
88class SubProcessTool (QtCore .QObject ):
9- """辅助QProcess使用的工具类,将所有直接对子进程进行的操作都封装在此类中"""
9+ """
10+ 辅助QProcess使用的工具类,将所有直接对子进程进行的操作都封装在此类中
11+ """
1012
11- # 自定义信号,参数为 tuple[output_type: SubProcessTool.output_type , output_text: str]
13+ # 自定义信号,参数为 tuple[output_type: int , output_text: str]
1214 output = QtCore .Signal (tuple )
1315
1416 # output_types
@@ -30,7 +32,6 @@ def __init__(
3032 :param program: 待运行的子进程
3133 :param arguments: 运行参数
3234 :param working_directory: 子进程工作目录
33- :return: None
3435 """
3536
3637 super (SubProcessTool , self ).__init__ (parent )
@@ -50,7 +51,6 @@ def start_process(
5051 """
5152 创建并启动子进程 \n
5253 :param mode: 设备打开的模式
53- :return: None
5454 """
5555
5656 if self ._process is None : # 防止在子进程运行结束前重复启动
@@ -87,7 +87,6 @@ def set_arguments(self, arguments: Sequence[str]) -> None:
8787 """
8888 设置子进程参数 \n
8989 :param arguments: 参数列表
90- :return: None
9190 """
9291
9392 self ._arguments = arguments
@@ -108,7 +107,6 @@ def set_working_dir(self, work_dir: str) -> bool:
108107 def _process_started (self ) -> None :
109108 """
110109 处理子进程开始的槽 \n
111- :return: None
112110 """
113111
114112 pass
@@ -118,7 +116,6 @@ def _process_finished(self, code: int, status: QtCore.QProcess.ExitStatus) -> No
118116 处理子进程结束的槽 \n
119117 :param code: 退出码
120118 :param status: 退出状态
121- :return: None
122119 """
123120
124121 self .exit_code = code
@@ -129,7 +126,6 @@ def _process_finished(self, code: int, status: QtCore.QProcess.ExitStatus) -> No
129126 def _handle_stdout (self ) -> None :
130127 """
131128 处理标准输出的槽 \n
132- :return: None
133129 """
134130
135131 if self ._process :
@@ -140,7 +136,6 @@ def _handle_stdout(self) -> None:
140136 def _handle_stderr (self ) -> None :
141137 """
142138 处理标准错误的槽 \n
143- :return: None
144139 """
145140
146141 if self ._process :
@@ -152,13 +147,12 @@ def _handle_state(self, state: QtCore.QProcess.ProcessState) -> None:
152147 """
153148 将子进程运行状态转换为易读形式 \n
154149 :param state: 进程运行状态
155- :return: None
156150 """
157151
158152 states = {
159- QtCore .QProcess .NotRunning : "Not running " ,
160- QtCore .QProcess .Starting : "Starting " ,
161- QtCore .QProcess .Running : "Running " ,
153+ QtCore .QProcess .NotRunning : "非运行 " ,
154+ QtCore .QProcess .Starting : "启动中…… " ,
155+ QtCore .QProcess .Running : "正在运行中…… " ,
162156 }
163157 state_name = states [state ]
164158 self .output .emit ((self .STATE , state_name ))
@@ -167,7 +161,6 @@ def _handle_error(self, error: QtCore.QProcess.ProcessError) -> None:
167161 """
168162 处理子进程错误 \n
169163 :param error: 子进程错误
170- :return: None
171164 """
172165
173166 pass
0 commit comments