Loading generateBaseline/postprocessing.py +19 −3 Original line number Original line Diff line number Diff line Loading @@ -155,9 +155,17 @@ def refresh_docx_fields(input_path: str, image: str = "docx-field-refresh") -> s # Convert Path to string for Docker commands # Convert Path to string for Docker commands mount_point_host_str = str(mount_point_host) mount_point_host_str = str(mount_point_host) # Verify host path exists if not mount_point_host.exists(): raise FileNotFoundError(f"Mount point does not exist on host: {mount_point_host_str}") if not mount_point_host.is_dir(): raise ValueError(f"Mount point is not a directory: {mount_point_host_str}") print(f"📂 Mount point (host): {mount_point_host_str}") print(f"📂 Mount point (host): {mount_point_host_str}") print(f"📂 Mount point (host absolute): {mount_point_host.absolute()}") print(f"📂 Mount point (container): {mount_point_container}") print(f"📂 Mount point (container): {mount_point_container}") print(f"📂 File path in container: {file_path_in_container}") print(f"📂 File path in container: {file_path_in_container}") print(f"📂 Mount syntax: -v {mount_point_host_str}:{mount_point_container}") # Run LibreOffice to refresh fields (convert docx to docx refreshes fields) # Run LibreOffice to refresh fields (convert docx to docx refreshes fields) # Then run post-processing command in the same container # Then run post-processing command in the same container Loading @@ -182,8 +190,8 @@ def refresh_docx_fields(input_path: str, image: str = "docx-field-refresh") -> s cmd = [ cmd = [ "docker", "run", "--rm", "docker", "run", "--rm", "-v", f"{mount_point_host_str}:{mount_point_container}", "-v", f'{mount_point_host_str}:{mount_point_container}', "-e", f"HOME={mount_point_container}", "-e", f'HOME={mount_point_container}', "--entrypoint", "/bin/bash", "--entrypoint", "/bin/bash", image, image, "-c", combined_cmd, "-c", combined_cmd, Loading @@ -199,12 +207,18 @@ def refresh_docx_fields(input_path: str, image: str = "docx-field-refresh") -> s # Run diagnostic commands in the container # Run diagnostic commands in the container print(f"🔍 Running diagnostic commands in CONTAINER...") print(f"🔍 Running diagnostic commands in CONTAINER...") print(f"🔍 Mount: {mount_point_host_str} -> {mount_point_container}") print(f"🔍 Mount: {mount_point_host_str} -> {mount_point_container}") # First, test if we can see a known file from host in container test_file = mount_point_host / "baseline" / input_path.name print(f"🔍 Expected file on host: {test_file}") print(f"🔍 File exists on host: {test_file.exists()}") diag_cmd = [ diag_cmd = [ "docker", "run", "--rm", "docker", "run", "--rm", "-v", f"{mount_point_host_str}:{mount_point_container}", "-v", f"{mount_point_host_str}:{mount_point_container}", "--entrypoint", "/bin/bash", "--entrypoint", "/bin/bash", image, image, "-c", f"echo '=== Container Diagnostics ===' && echo 'Mount point: {mount_point_container}' && pwd && whoami && echo '=== /data contents ===' && ls -la {mount_point_container} && echo '=== Checking mount ===' && test -f {file_path_in_container} && echo 'File exists in container!' || echo 'File NOT found in container' && echo '=== /data/baseline contents ===' && ls -la {mount_point_container}/baseline/ 2>/dev/null || echo 'No baseline directory' && echo '=== Checking if file exists in container ===' && ls -la {file_path_in_container} 2>/dev/null || echo 'File not found: {file_path_in_container}'", "-c", f"echo '=== Container Diagnostics ===' && echo 'Mount: {mount_point_host_str} -> {mount_point_container}' && echo 'Current directory:' && pwd && echo 'User:' && whoami && echo '' && echo '=== Testing mount ===' && echo 'Checking if {mount_point_container} is a directory:' && test -d {mount_point_container} && echo 'YES' || echo 'NO' && echo 'Checking if {mount_point_container} is mounted:' && mountpoint -q {mount_point_container} && echo 'YES (mountpoint)' || echo 'NO (mountpoint)' && echo '' && echo '=== {mount_point_container} contents ===' && ls -la {mount_point_container} && echo '' && echo '=== {mount_point_container}/baseline contents ===' && ls -la {mount_point_container}/baseline/ 2>/dev/null || echo 'No baseline directory' && echo '' && echo '=== Checking if file exists ===' && test -f {file_path_in_container} && echo 'FILE EXISTS: {file_path_in_container}' || echo 'FILE NOT FOUND: {file_path_in_container}' && ls -la {file_path_in_container} 2>/dev/null || true", ] ] subprocess.run(diag_cmd, check=False) # Don't fail if diagnostic fails subprocess.run(diag_cmd, check=False) # Don't fail if diagnostic fails Loading Loading @@ -305,6 +319,8 @@ def update_toc(docx_input, docx_output): # Write to output file # Write to output file shutil.move(tmp_path, docx_output) shutil.move(tmp_path, docx_output) # Set proper permissions (read/write for owner, read for group and others) os.chmod(docx_output, 0o644) finally: finally: # delete temp file if still existing # delete temp file if still existing Loading Loading
generateBaseline/postprocessing.py +19 −3 Original line number Original line Diff line number Diff line Loading @@ -155,9 +155,17 @@ def refresh_docx_fields(input_path: str, image: str = "docx-field-refresh") -> s # Convert Path to string for Docker commands # Convert Path to string for Docker commands mount_point_host_str = str(mount_point_host) mount_point_host_str = str(mount_point_host) # Verify host path exists if not mount_point_host.exists(): raise FileNotFoundError(f"Mount point does not exist on host: {mount_point_host_str}") if not mount_point_host.is_dir(): raise ValueError(f"Mount point is not a directory: {mount_point_host_str}") print(f"📂 Mount point (host): {mount_point_host_str}") print(f"📂 Mount point (host): {mount_point_host_str}") print(f"📂 Mount point (host absolute): {mount_point_host.absolute()}") print(f"📂 Mount point (container): {mount_point_container}") print(f"📂 Mount point (container): {mount_point_container}") print(f"📂 File path in container: {file_path_in_container}") print(f"📂 File path in container: {file_path_in_container}") print(f"📂 Mount syntax: -v {mount_point_host_str}:{mount_point_container}") # Run LibreOffice to refresh fields (convert docx to docx refreshes fields) # Run LibreOffice to refresh fields (convert docx to docx refreshes fields) # Then run post-processing command in the same container # Then run post-processing command in the same container Loading @@ -182,8 +190,8 @@ def refresh_docx_fields(input_path: str, image: str = "docx-field-refresh") -> s cmd = [ cmd = [ "docker", "run", "--rm", "docker", "run", "--rm", "-v", f"{mount_point_host_str}:{mount_point_container}", "-v", f'{mount_point_host_str}:{mount_point_container}', "-e", f"HOME={mount_point_container}", "-e", f'HOME={mount_point_container}', "--entrypoint", "/bin/bash", "--entrypoint", "/bin/bash", image, image, "-c", combined_cmd, "-c", combined_cmd, Loading @@ -199,12 +207,18 @@ def refresh_docx_fields(input_path: str, image: str = "docx-field-refresh") -> s # Run diagnostic commands in the container # Run diagnostic commands in the container print(f"🔍 Running diagnostic commands in CONTAINER...") print(f"🔍 Running diagnostic commands in CONTAINER...") print(f"🔍 Mount: {mount_point_host_str} -> {mount_point_container}") print(f"🔍 Mount: {mount_point_host_str} -> {mount_point_container}") # First, test if we can see a known file from host in container test_file = mount_point_host / "baseline" / input_path.name print(f"🔍 Expected file on host: {test_file}") print(f"🔍 File exists on host: {test_file.exists()}") diag_cmd = [ diag_cmd = [ "docker", "run", "--rm", "docker", "run", "--rm", "-v", f"{mount_point_host_str}:{mount_point_container}", "-v", f"{mount_point_host_str}:{mount_point_container}", "--entrypoint", "/bin/bash", "--entrypoint", "/bin/bash", image, image, "-c", f"echo '=== Container Diagnostics ===' && echo 'Mount point: {mount_point_container}' && pwd && whoami && echo '=== /data contents ===' && ls -la {mount_point_container} && echo '=== Checking mount ===' && test -f {file_path_in_container} && echo 'File exists in container!' || echo 'File NOT found in container' && echo '=== /data/baseline contents ===' && ls -la {mount_point_container}/baseline/ 2>/dev/null || echo 'No baseline directory' && echo '=== Checking if file exists in container ===' && ls -la {file_path_in_container} 2>/dev/null || echo 'File not found: {file_path_in_container}'", "-c", f"echo '=== Container Diagnostics ===' && echo 'Mount: {mount_point_host_str} -> {mount_point_container}' && echo 'Current directory:' && pwd && echo 'User:' && whoami && echo '' && echo '=== Testing mount ===' && echo 'Checking if {mount_point_container} is a directory:' && test -d {mount_point_container} && echo 'YES' || echo 'NO' && echo 'Checking if {mount_point_container} is mounted:' && mountpoint -q {mount_point_container} && echo 'YES (mountpoint)' || echo 'NO (mountpoint)' && echo '' && echo '=== {mount_point_container} contents ===' && ls -la {mount_point_container} && echo '' && echo '=== {mount_point_container}/baseline contents ===' && ls -la {mount_point_container}/baseline/ 2>/dev/null || echo 'No baseline directory' && echo '' && echo '=== Checking if file exists ===' && test -f {file_path_in_container} && echo 'FILE EXISTS: {file_path_in_container}' || echo 'FILE NOT FOUND: {file_path_in_container}' && ls -la {file_path_in_container} 2>/dev/null || true", ] ] subprocess.run(diag_cmd, check=False) # Don't fail if diagnostic fails subprocess.run(diag_cmd, check=False) # Don't fail if diagnostic fails Loading Loading @@ -305,6 +319,8 @@ def update_toc(docx_input, docx_output): # Write to output file # Write to output file shutil.move(tmp_path, docx_output) shutil.move(tmp_path, docx_output) # Set proper permissions (read/write for owner, read for group and others) os.chmod(docx_output, 0o644) finally: finally: # delete temp file if still existing # delete temp file if still existing Loading