pysmb and storing files remotely

Dave Harrison dave at nullcube.com
Tue Feb 18 00:28:49 EST 2003


Hey gurus of the python persuasion,

Im using the pysmb library to store files on a windows server.  I can login and list dirs and all the other stuff without problems.  However storing files is another matter ....

my code is as follows (as according the the example included with the source code) :

sz = file(filename, 'rb')
fileshare = smb.SMB('dig', '111.11.11.11', my_name = None, host_type = nmb.TYPE_SERVER, sess_port = nmb.NETBIOS_SESSION_PORT)
    fileshare.login(login, getpass.getpass('Enter your password -> '))
    fileshare.stor_file('Call', remote_path+filename, sz.read)

However I get the following error :

Traceback (most recent call last):
  File "./heat_pw_attach", line 45, in ?
    main()
  File "./heat_pw_attach", line 37, in main
    placeFile(filename, sh_login)
  File "./heat_pw_attach", line 16, in placeFile
    fileshare.stor_file('Call', remote_path+filename, sz.read)
  File "smb.py", line 848, in stor_file
    self.__nonraw_stor_file(tid, fid, offset, datasize, callback, timeout)
  File "smb.py", line 570, in __nonraw_stor_file
    write_offset = write_offset + unpack('<H', params[4+offset:6+offset])[0]
struct.error: unpack str size does not match format

The doco states the following :

stor_file(service, filename, callback, mode = SMB_O_CREAT | SMB_O_TRUNC, offset = 0, timeout = None)
    Store a file of filename in service by reading from the callback function. filename should be a fully-qualified path name of the file (excluding the service component). offset is used to indicate where to start writing. password is the authentication info required for access if this service is in share mode and is protected. The callback function should be able to take an int argument which indicates how many bytes to return as the file data. Raises nmb.NetBIOSTimeout if timeout (in secs) waiting for reply. Raises smb.SessionError if error occurs.

But Im lost as to what the actual problem here is, or even what the function itself asks for.

Can anyone explain the exact arguments the function requests a bit better for me ?

Thanks
Dave





More information about the Python-list mailing list