1. 增加无网络环境使用的逻辑 2. 优化EC指令发送的逻辑

This commit is contained in:
2025-03-31 11:21:13 +08:00
parent 676eb49679
commit 671db5b1db
5 changed files with 86 additions and 73 deletions

View File

@ -2,8 +2,6 @@ import os
import os.path
import threading
import sqlite3
import time
from PySide6.QtCore import Signal, QThread

View File

@ -1753,7 +1753,7 @@ class ExternalCommunication(QThread):
clibs.c_hr.execution("socket.set_params", enable=True, ip="0.0.0.0", port=str(self.port), suffix="\r", type=1)
# time.sleep(clibs.INTERVAL*2)
self.c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.c.settimeout(clibs.INTERVAL*5)
self.c.settimeout(clibs.INTERVAL*3)
try:
self.c.connect((self.ip, self.port))
self.logger("INFO", "openapi", f"ec: 外部通信连接成功...", "green")
@ -1782,7 +1782,8 @@ class ExternalCommunication(QThread):
try:
char = self.c.recv(1).decode(encoding="unicode_escape")
except Exception as err:
self.logger("ERROR", "openapi", f"ec: 获取请求指令 {directive} 的返回数据超时,需确认指令发送格式以及内容正确!具体报错信息如下 {err}", "red")
result = [f"ec: 获取请求指令 {directive} 的返回数据超时,需确认指令发送格式以及内容正确!具体报错信息如下 {err}", "error"]
return result
result = "".join([result, char])
return result
@ -2033,6 +2034,7 @@ class PreDos(object):
self.ssh_port = ssh_port
self.username = username
self.password = password
self.logger = clibs.logger
def __ssh2server(self):
try:
@ -2041,8 +2043,7 @@ class PreDos(object):
self.__ssh.connect(hostname=self.ip, port=self.ssh_port, username=self.username, password=self.password)
self.__sftp = self.__ssh.open_sftp()
except Exception as err:
print(f"predos: SSH 无法连接到 {self.ip}:{self.ssh_port},需检查网络连通性或者登录信息是否正确 {err}")
raise Exception("SshConnFailed")
self.logger("ERROR", "openapi", f"predos: SSH 无法连接到 {self.ip}:{self.ssh_port},需检查网络连通性或者登录信息是否正确 {err}", "red")
def push_prj_to_server(self, prj_file):
# prj_file本地工程完整路径