I have a NAS device that appears in Finder under the Shared devices so I can read and write to it just like any folder on my OSX drive with no need to provide authentication. How can I read and write to it from Python code? I have tried manually accessing required folders on the drive so that they then appear in Volumes, but I still can't get at them.
closed as off-topic by Allan, Nimesh Neema, IconDaemon, nohillside♦ Jan 21 at 7:32
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions about software development are off-topic here, but can be asked on Stack Overflow." – Allan, Nimesh Neema, IconDaemon, nohillside
If you want to mount the network volume (or make sure that it is mounted) from the python code, then you could use the shell command
mount, from inside an
os.system() call. See this answer.
Once mounted, you can access the contents of the drive like any other connected drive with a filepath under /Volumes.
It is likely to be something like:
/Volumes/My\ NAS/path/to/file (where "My NAS" is the name of your share.)
Note that whether the Finder shows the drive under "Devices" or "Shared" is irrelevant.
If you need to find the filepath for a given item on the NAS, use Command Alt C in the Finder to copy the filepath to the clipboard as text.
If the correct path still isn't working in your python, then we need to see your python code.