Skip to content

Commit

Permalink
check perm
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxuanzhuang committed Dec 8, 2024
1 parent e550746 commit 243bb3a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 0 additions & 2 deletions package/MDAnalysis/coordinates/XDR.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import errno
import numpy as np
import os
from pathlib import Path

from os.path import getctime, getsize, isfile, split, join
import warnings
Expand Down Expand Up @@ -200,7 +199,6 @@ def _load_offsets(self):

# check if the location of the lock is writable.
try:
Path(lock_name).parent.mkdir(parents=True, exist_ok=True)
with FileLock(lock_name) as filelock:
pass
except OSError as e:
Expand Down
13 changes: 11 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_xdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#
import pytest
from unittest.mock import patch

from time import time
import re
import os
import shutil
Expand Down Expand Up @@ -897,13 +897,22 @@ def test_persistent_offsets_readonly(self, tmpdir):
if os.name == 'nt':
# Windows platform: deny write access using `icacls`
subprocess.run(
f"icacls {tmpdir} /deny Users:W",
f"icacls {tmpdir} /deny Users:W /T",
shell=True,
check=True # Raises an error if the command fails
)
# print the permissions to check if they are set correctly
subprocess.run(
f'icacls {tmpdir}',
shell=True,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
else:
# Non-Windows platforms: use chmod for read and execute only
os.chmod(str(tmpdir), 0o555)
time.sleep(1) # wait for permissions to be set

filename = str(tmpdir.join(os.path.basename(self.filename)))
# try to write a offsets file
Expand Down

0 comments on commit 243bb3a

Please sign in to comment.