6๐
You should take a look on net use
Windows command. It lets you to mount any network resources with given credentials.
Before accessing network resource, you can execute from Python net use
command, like this:
net use \\computername\path\to\dir /user:username password
If credentials are correct, network resource will be accessible, and os.listdir()
will work.
There can be some issues if given resource was already mounted with different credentials. In such case you should unmount them first (net use \\computername\path\to\dir /delete
)
0๐
According to the Python manual os.listdir(path)
only takes the path
name as the argument. It probably works for you locally using the Django test server as permissions are different in that environment than using a production webserver like Apache or Nginx. Try looking at the following pre-existing related SO questions and answers โ they might offer you some guidance, especially on a Win box:
What is the best way to map windows drives using Python?
python copy files to a network location on Windows without mapping a drive