Skip to content

Commit 34062ec

Browse files
committed
chmod fix
1 parent c62d51a commit 34062ec

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tests/integration/image_checker.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ def set_up_and_run_image_checker(
6161
"diff_dir": f"{actual_images_dir}image_check_failures_{cfg_specifier}{diff_dir_suffix}",
6262
"expected_images_list": f"{expansions['expected_dir']}image_list_expected_{cfg_specifier}.txt",
6363
}
64+
print(f"Removing diff_dir={d['diff_dir']} to produce new results")
65+
if os.path.exists(d["diff_dir"]):
66+
shutil.rmtree(d["diff_dir"])
6467
print("Image checking dict:")
6568
for key in d:
6669
print(f"{key}: {d[key]}")
@@ -181,7 +184,7 @@ def _check_mismatched_images(
181184

182185
# Make diff_dir readable
183186
if os.path.exists(parameters.diff_dir):
184-
os.system(f"chmod -R 755 {parameters.diff_dir}")
187+
_chmod_recursive(parameters.diff_dir, 0o755)
185188
else:
186189
# diff_dir won't exist if all the expected images are missing
187190
# That is, if we're in this case, we expect the following:
@@ -278,6 +281,21 @@ def _draw_box(image, diff, output_path: str):
278281
image.save(output_path, "PNG")
279282

280283

284+
def _chmod_recursive(path: str, mode):
285+
root: str
286+
dirs: List[str]
287+
files: List[str]
288+
for root, dirs, files in os.walk(path):
289+
for name in dirs:
290+
dir_path: str = os.path.join(root, name)
291+
os.chmod(dir_path, mode)
292+
for name in files:
293+
file_path: str = os.path.join(root, name)
294+
os.chmod(file_path, mode)
295+
# Also chmod the root directory itself
296+
os.chmod(path, mode)
297+
298+
281299
# TODO: fix issue where blank plots generate after so many pages in the PDF
282300
def _make_image_diff_grid(diff_subdir, pdf_name="image_diff_grid.pdf", rows_per_page=2):
283301
machine_info = MachineInfo()

0 commit comments

Comments
 (0)