From 1c1d47e3faf2385425ad23b9e2d4fe494bc1fdac Mon Sep 17 00:00:00 2001 From: Kenichiro NOGI Date: Sun, 2 Aug 2026 10:31:32 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E4=BB=BB=E6=84=8F=E5=81=9C=E6=AD=A2=E6=99=82=E3=81=AE=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E7=B5=90=E6=9E=9C=E3=82=92=E3=80=8C=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=80=8D=E3=81=8B=E3=82=89=E3=80=8C=E6=89=8B=E5=8B=95?= =?UTF-8?q?=E5=81=9C=E6=AD=A2=E3=80=8D=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 意図的な停止操作をエラー扱いすると、ログ確認時に異常発生と誤認するため専用カテゴリに分離。 Co-Authored-By: Claude Sonnet 5 --- .../superpowers/specs/2026-08-02-watch-launcher-design.md | 2 +- PythonProj/ScanOCR/スクリプト/extract_and_rename.py | 2 +- .../ScanOCR/スクリプト/tests/test_extract_and_rename.py | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/PythonProj/ScanOCR/docs/superpowers/specs/2026-08-02-watch-launcher-design.md b/PythonProj/ScanOCR/docs/superpowers/specs/2026-08-02-watch-launcher-design.md index 6694d0ac..c78bcdeb 100644 --- a/PythonProj/ScanOCR/docs/superpowers/specs/2026-08-02-watch-launcher-design.md +++ b/PythonProj/ScanOCR/docs/superpowers/specs/2026-08-02-watch-launcher-design.md @@ -120,7 +120,7 @@ DPI=300 - 出力先: `ログ/YYYY-MM-DD.log`(日付別、UTF-8 BOM付き) - 1件1行、フォーマット: ``` - [YYYY-MM-DD HH:MM:SS] 結果=成功|失敗|スキップ|エラー | 元ファイル=xxx.pdf | 氏名=xxx | 日付=xxx | 備考=... + [YYYY-MM-DD HH:MM:SS] 結果=成功|失敗|スキップ|エラー|手動停止 | 元ファイル=xxx.pdf | 氏名=xxx | 日付=xxx | 備考=... ``` - エラー時、備考欄にスタックトレース概要含める diff --git a/PythonProj/ScanOCR/スクリプト/extract_and_rename.py b/PythonProj/ScanOCR/スクリプト/extract_and_rename.py index 46a35a63..158a49d3 100644 --- a/PythonProj/ScanOCR/スクリプト/extract_and_rename.py +++ b/PythonProj/ScanOCR/スクリプト/extract_and_rename.py @@ -186,7 +186,7 @@ def run_queue( if key_check(): append_log( - log_dir, "エラー", pdf_path.name, None, None, + log_dir, "手動停止", pdf_path.name, None, None, "ユーザー操作により停止しました", ) break diff --git a/PythonProj/ScanOCR/スクリプト/tests/test_extract_and_rename.py b/PythonProj/ScanOCR/スクリプト/tests/test_extract_and_rename.py index 8a6aec85..dd94dfe3 100644 --- a/PythonProj/ScanOCR/スクリプト/tests/test_extract_and_rename.py +++ b/PythonProj/ScanOCR/スクリプト/tests/test_extract_and_rename.py @@ -157,6 +157,11 @@ def test_run_queue_stops_on_key_press(tmp_path): assert calls == [] assert pdf.exists() # 処理されず残る + from datetime import datetime + log_content = (dirs["log"] / f"{datetime.now().strftime('%Y-%m-%d')}.log").read_text(encoding="utf-8-sig") + assert "結果=手動停止" in log_content + assert "結果=エラー" not in log_content + def test_run_queue_skips_file_deleted_before_processing(tmp_path): dirs = _make_dirs(tmp_path)