Skip to content

Commit

Permalink
整理代码
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroi-sora committed Mar 4, 2023
1 parent b2546dd commit b3a8737
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 11 deletions.
4 changes: 0 additions & 4 deletions ocr/api_ppocr_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ def __init__(self, exePath, configPath="", argsStr=""):

# 子线程检查超时
def cancelTimeout():
# print('进程启动计时器取消')
checkTimer.cancel()

def checkTimeout():
# print('进程启动计时器触发')
self.initErrorMsg = f'OCR init timeout: {InitTimeout}s.\n{exePath}'
self.ret.kill() # 关闭子进程
checkTimer = threading.Timer(InitTimeout, checkTimeout)
Expand All @@ -72,7 +70,6 @@ def checkTimeout():
if 'OCR init completed.' in initStr: # 初始化成功
break
cancelTimeout()
# print(f'初始化OCR成功,进程号为{self.ret.pid}')

def run(self, imgPath):
"""对一张图片文字识别。\n
Expand Down Expand Up @@ -113,7 +110,6 @@ def getRam(self):
try:
return int(self.psutilProcess.memory_info().rss/1048576)
except Exception as e:
print(f'获取子进程内存失败:{e}')
return -1

def __del__(self):
Expand Down
1 change: 0 additions & 1 deletion ocr/engine_ram_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def runBefore(self, ram):
ramMax = Config.get('ocrRamMaxFootprint')
if ramMax > 0:
if ram > ramMax:
print(f'内存占用超标!!!')
self.restart()

def runAfter(self):
Expand Down
2 changes: 1 addition & 1 deletion ui/win_ocr_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _initWin(self):
self.win = tk.Toplevel()
self.win.iconphoto(False, Asset.getImgTK('umiocr24')) # 设置窗口图标
self.win.minsize(250, 340) # 最小大小
self.win.geometry(f"{250}x{340}")
self.win.geometry(f'{250}x{340}')
self.win.unbind('<MouseWheel>')
self.win.title('更改语言')
self.win.wm_protocol( # 注册窗口关闭事件
Expand Down
8 changes: 5 additions & 3 deletions utils/command_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,13 @@ async def __listener(self): # 监听器
while True:
try:
# 读取命名管道数据
data = win32file.ReadFile(
pipe, pipeBufferSize)[1].decode()
indata = win32file.ReadFile(
pipe, pipeBufferSize)
print(f"==============读取数据:\n{indata}")
data = indata[1].decode()
ParseStr(data) # 分析并执行
except Exception as e:
# print(f"读取数据出错:{e}")
print(f"读取数据出错:{e}")
break
finally: # 某个客户端断开连接
try:
Expand Down
2 changes: 1 addition & 1 deletion utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def initLogger(self):
formatPrint = logging.Formatter(
'【%(levelname)s】 %(message)s')
streamHandler.setFormatter(formatPrint)
self.logger.addHandler(streamHandler)
# self.logger.addHandler(streamHandler)

return
# 日志文件
Expand Down
1 change: 0 additions & 1 deletion utils/pynput_hotkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def __call__(self, key):
char = self._normalLayout[scan][0] # 扫描码转char
return char.lower()
except Exception as e: # 特殊键(如Fn)没有对应字符,会跳到这里
# print(f'翻译错误:{e} 事件对象:{key}')
if key and hasattr(key, 'vk'):
return f'<{key.vk}>' # 未知键值,无对应字符,返回键值本身
else:
Expand Down

0 comments on commit b3a8737

Please sign in to comment.