Apr-18-2019, 08:11 AM
The resource you're trying to access is a samba share. First you have to mount the resource or use a library to access direct to samba shares. I guess new servers don't support the old samba protocol. Maybe this module works: https://github.com/jborean93/smbprotocol
Otherwise you can use subprocess to run the net command to mount a samba share.
I check in the function the return value of the net command.
Maybe you want some information if there were an error and why.
Otherwise you can use subprocess to run the net command to mount a samba share.
from subprocess import Popen, PIPE def mount_share(path, target, persistent=False): cmd = ['net', 'use', target, path] if persistent: cmd.append('/PERSISTENT:YES') proc = Popen(cmd, stdout=PIPE, stderr=PIPE) retval = proc.wait() if retval != 0: raise ValueError(proc.stderr.read())Then you can access with Python the mounted share, just like with normal files.
I check in the function the return value of the net command.
Maybe you want some information if there were an error and why.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!