ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
pysmb and storing files remotely
by Dave Harrison other posts by this author
Feb 17 2003 9:28PM messages near this date
ANN: twander 3.0 Released | Script to fetch IMAP unread / unseen message counts?
Hey gurus of the python persuasion,

Im using the pysmb library to store files on a windows server.  I can login and list dirs an
d 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 shou
ld be a fully-qualified path name of the file (excluding the service component). offset is u
sed to indicate where to start writing. password is the authentication info required for acc
ess 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 nm
b.NetBIOSTimeout if timeout (in secs) waiting for reply. Raises smb.SessionError if error oc
curs.

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

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved