From afc011883030c947e41c285d9a00a783805a0005 Mon Sep 17 00:00:00 2001 From: lededev Date: Mon, 27 Sep 2021 06:39:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B1=E8=B0=83=E7=94=A8flush()=E6=94=B9?= =?UTF-8?q?=E4=B8=BAhook=20print()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AV_Data_Capture.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/AV_Data_Capture.py b/AV_Data_Capture.py index bd79252..edd1ecd 100755 --- a/AV_Data_Capture.py +++ b/AV_Data_Capture.py @@ -126,6 +126,13 @@ def close_logfile(logdir: str): pass +_print = print # Hook print +_stdout = sys.stdout +def print(*args, **kw): + _print(*args, **kw) + if _stdout != sys.stdout: + sys.stdout.flush() + # 重写视频文件扫描,消除递归,取消全局变量,新增失败文件列表跳过处理 def movie_lists(root, conf, regexstr): @@ -333,7 +340,6 @@ f'[!]运行模式:**维护模式**,本程序将在处理{count_all}个视频 percentage = str(count / int(count_all) * 100)[:4] + '%' print('[!] - ' + percentage + ' [' + str(count) + '/' + count_all + '] -') create_data_and_move(movie_path, conf, conf.debug()) - sys.stdout.flush() if count >= stop_count: print("[!]Stop counter triggered!") break