Prevent "os.chdir" from resolving a symbolic link

On all computers in my cluster, my home directory is mounted from an NFS server as /home/drive1/username. On an NFS server, the folder /home/drive1/usernameis a symbolic link to /drive1/username.

Duration:

$ python -c "import os; os.chdir('/home/drive1/username'); print(os.getcwd())"

on any computer other than printing an NFS server:

/home/drive1/username

but on the NFS server the same command prints:

/drive1/username

Is there a way to prevent Python from moving os.chdirthrough a symbolic link? This makes it difficult to determine the correct path when sending jobs from the NFS server to work nodes.


Edit

note that

cd /home/drive1/username
pwd

works like on all machines.

+1
source share

No one has answered this question yet.

Source: https://habr.com/ru/post/1695689/


All Articles