I\'m sure this is a easy question, my Google-fu is obviously failing me.
How do I mount a filesystem using Python, the equivalent of running the shell command
I know this is old but I had a similar issue and pexpect solved it. I could mount my Windows shared drive using the mount command but I couldn't pass my password in because it had to be escaped. I grew tired of escaping it and tried to use a credentials file which also caused issues. This seems to work for me.
password = "$wirleysaysneverquit!!!"
cmd = "sudo mount -t cifs -o username=myusername,domain=CORPORATE,rw,hard,nosetuids,noperm,sec=ntlm //mylong.evenlonger.shareddrivecompany.com/some/folder /mnt/folder -v"
p = pexpect.spawn( cmd )
p.expect( ": " )
print( p.before + p.after + password )
p.sendline( password )
p.expect( "\r\n" )
output = p.read()
arroutput = output.split("\r\n")
for o in arroutput:
print( o )
Source: https://gist.github.com/nitrocode/192d5667ce9da67c8eac