import os def ensure_output_dir(): """Ensure the output directory exists and is writable.""" output_dir = os.path.join(os.getcwd(), "output") if not os.path.exists(output_dir): os.makedirs(output_dir) # Ensure the directory is writable if not os.access(output_dir, os.W_OK): os.chmod(output_dir, 0o777)