界面优化,监控逻辑优化
This commit is contained in:
@ -7,20 +7,14 @@ from codes.common import clibs
|
||||
|
||||
|
||||
class IsoDataProcess(QThread):
|
||||
output = Signal(str, str)
|
||||
|
||||
def __init__(self, dir_path, /):
|
||||
super().__init__()
|
||||
self.dir_path = dir_path
|
||||
self.idx = 2
|
||||
self.logger = clibs.logger
|
||||
|
||||
def logger(self, level, module, content, color="black", error="", flag="both"):
|
||||
flag = "cursor" if level.upper() == "DEBUG" else "both"
|
||||
clibs.logger(level, module, content, color, flag, signal=self.output)
|
||||
if level.upper() == "ERROR":
|
||||
raise Exception(f"{error} | {content}")
|
||||
|
||||
def p_iso(self, file, p_files, ws, tmpfile):
|
||||
@staticmethod
|
||||
def p_iso(file, p_files, ws, tmpfile):
|
||||
p_files.append(file)
|
||||
|
||||
pdf = pdfplumber.open(file)
|
||||
@ -79,7 +73,8 @@ class IsoDataProcess(QThread):
|
||||
pass
|
||||
pdf.close()
|
||||
|
||||
def p_iso_100(self, file, p_files, ws, tmpfile):
|
||||
@staticmethod
|
||||
def p_iso_100(file, p_files, ws, tmpfile):
|
||||
p_files.append(file)
|
||||
|
||||
pdf = pdfplumber.open(file)
|
||||
@ -112,7 +107,8 @@ class IsoDataProcess(QThread):
|
||||
pass
|
||||
pdf.close()
|
||||
|
||||
def p_iso_1000(self, file, p_files, ws, tmpfile):
|
||||
@staticmethod
|
||||
def p_iso_1000(file, p_files, ws, tmpfile):
|
||||
p_files.append(file)
|
||||
|
||||
pdf = pdfplumber.open(file)
|
||||
@ -146,9 +142,9 @@ class IsoDataProcess(QThread):
|
||||
pdf.close()
|
||||
|
||||
def initialization(self):
|
||||
dirs, files = clibs.traversal_files(self.dir_path, self.output)
|
||||
dirs, files = clibs.traversal_files(self.dir_path)
|
||||
if len(dirs) != 0:
|
||||
self.logger("ERROR", "iso", f"init: 工作目录下不可以有文件夹!", "red", "InitFileError")
|
||||
self.logger("ERROR", "iso", f"init: 工作目录下不可以有文件夹!", "red")
|
||||
|
||||
for file in files:
|
||||
file = file.lower()
|
||||
@ -161,7 +157,7 @@ class IsoDataProcess(QThread):
|
||||
elif file.endswith("iso.pdf"):
|
||||
pass
|
||||
else:
|
||||
self.logger("ERROR", "iso", f"init: 工作目录下只允许有如下四个文件,不区分大小写,pdf文件最少有一个!<br>1. iso-results.xlsx<br>2. ISO.pdf<br>3. ISO-V100.pdf<br>4. ISO-V1000.pdf", "red", "InitFileError")
|
||||
self.logger("ERROR", "iso", f"init: 工作目录下只允许有如下四个文件,不区分大小写,pdf文件最少有一个!<br>1. iso-results.xlsx<br>2. ISO.pdf<br>3. ISO-V100.pdf<br>4. ISO-V1000.pdf", "red")
|
||||
|
||||
return files
|
||||
|
||||
@ -178,8 +174,8 @@ class IsoDataProcess(QThread):
|
||||
ws = wb.active
|
||||
for i in range(3, 50):
|
||||
ws.cell(row=i, column=7).value = None
|
||||
except Exception as Err:
|
||||
self.logger("ERROR", "iso", f"main: 无法打开文件 {filename}<br>{Err}", "red", "FileOpenError")
|
||||
except Exception as err:
|
||||
self.logger("ERROR", "iso", f"main: 无法打开文件 {filename}<br>{err}", "red")
|
||||
|
||||
p_files = []
|
||||
for file in files:
|
||||
@ -204,11 +200,11 @@ class IsoDataProcess(QThread):
|
||||
wb.close()
|
||||
|
||||
if len(p_files) == 0:
|
||||
self.logger("ERROR", "iso", f"目录 {self.dir_path} 下没有需要处理的文件,需要确认......", "red", "FileNotFound")
|
||||
self.logger("ERROR", "iso", f"目录 {self.dir_path} 下没有需要处理的文件,需要确认......", "red")
|
||||
else:
|
||||
os.remove(tmpfile)
|
||||
|
||||
self.logger("INFO", "current-processing", "-" * 60 + "<br>全部处理完毕<br>", "purple")
|
||||
time_total = time.time() - time_start
|
||||
msg = f"数据处理时间:{time_total // 3600:02.0f} h {time_total % 3600 // 60:02.0f} m {time_total % 60:02.0f} s\n"
|
||||
msg = f"数据处理时间:{time_total // 3600:02.0f} h {time_total % 3600 // 60:02.0f} m {time_total % 60:02.0f} s"
|
||||
self.logger("INFO", "current-processing", msg)
|
||||
|
Reference in New Issue
Block a user