From 9629266c4685ab8a4103e4117cc3eaf5383c98d4 Mon Sep 17 00:00:00 2001 From: Timothée Ravier Date: Apr 16 2024 13:24:39 +0000 Subject: postprocess: Debug for Python timestamp workaround Add some debug output to figure out if the logic of this workaround is correct. Updates: d085e9f postprocess: Workaround for Python timestamp mismatch See: https://pagure.io/workstation-ostree-config/pull-request/505 --- diff --git a/postprocess.sh b/postprocess.sh index c788ada..1d737d9 100755 --- a/postprocess.sh +++ b/postprocess.sh @@ -121,6 +121,7 @@ MIN_MAGIC = 3390 # The first magic number supporting PEP 552 ZERO = bytes((0, 0, 0, 0)) def pyc_set_zero_mtime(pyc_path): + print(f"{pyc_path}") with open(pyc_path, "r+b") as f: w = f.read(4) if len(w) < 4: @@ -136,18 +137,21 @@ def pyc_set_zero_mtime(pyc_path): if invalidation == ZERO: f.write(ZERO) + print(f"{pyc_path}: fixing mtime") return 1 return 0 if __name__ == "__main__": REGEX = re.compile(r".*/__pycache__/[^/]+\.cpython-.*(\.opt-1|\.opt-2)?\.pyc$") count = 0 + total = 0 for root, dirs, files in os.walk("/usr"): for file in files: path = os.path.join(root, file) if REGEX.match(path): + total += 1 count += pyc_set_zero_mtime(path) - print(f"Processed {count} pyc files") + print(f"Processed {count} pyc files (total: {total})") ' | python