mirror of
https://github.com/bellingcat/tiktok-hashtag-analysis.git
synced 2026-06-07 19:08:32 +03:00
made the process_output_dir function more reliable on Windows
This commit is contained in:
@@ -99,6 +99,11 @@ def process_output_dir(
|
||||
if not os.access(path=_output_dir, mode=os.W_OK):
|
||||
parser.error(error_message(_output_dir))
|
||||
else:
|
||||
# On Windows, os.access is unreliable
|
||||
temp_file = _output_dir / "test.txt"
|
||||
with open(temp_file, 'w') as f:
|
||||
f.write("test")
|
||||
os.remove(temp_file)
|
||||
return _output_dir
|
||||
except PermissionError:
|
||||
parser.error(error_message(_output_dir))
|
||||
|
||||
Reference in New Issue
Block a user