I am using the python-smbc library on Ubuntu to access a samba share. I can access the directory structure fine, I am however not sure how to access actual files and their c
I also have had trouble using smbfs (random system lockdowns and reboots) and needed a quick answer.
I've also tried the smbc module but couldn't get any data with it. I went just as far as accessing the directory structure, just like you.
Time was up and I had to deliver the code, so I took a shortcut:
I wrote a small wrapper around a "smbclient" call. It is a hack, ugly, really ugly, but it works for my needs. It is being used in production on the company I work.
Here's some example usage:
>>> smb = smbclient.SambaClient(server="MYSERVER", share="MYSHARE",
username='foo', password='bar', domain='baz')
>>> print smb.listdir(u"/")
[u'file1.txt', u'file2.txt']
>>> f = smb.open('/file1.txt')
>>> data = f.read()
>>> f.close()
>>> smb.rename(u'/file1.txt', u'/file1.old')
The programmer before me was using a "bash" file with lots of smbclient calls, so I think my solution is at least better.
I have uploaded it here, so you can use it if you want. Bitbucket repository is here. If you find a better solution please tell me and I'll replace my code too.