using pysamba library timeouts with large files
#1
Any scripters using the pysamba lybrary have experience transfering large files.

I can transfer text files and jpg's that are under 1MB. When I try and transfer large 12MB+ files it timeout.

Code:
import sys
import os
import xbmc
import xbmcgui
import smb
import nmb
import re
import traceback

def get_browse_dialog( default="", heading="", dlg_type=1, shares="files", mask="", use_thumbs=False, treat_as_folder=False ):
    """ shows a browse dialog and returns a value
        - 0 : ShowAndGetDirectory
        - 1 : ShowAndGetFile
        - 2 : ShowAndGetImage
        - 3 : ShowAndGetWriteableDirectory
    """
    dialog = xbmcgui.Dialog()
    value = dialog.browse( dlg_type, heading, shares, mask, use_thumbs, treat_as_folder, default )
    return value

filename = get_browse_dialog( heading = "File to copy" )
share_string = get_browse_dialog( heading = "Samba folder to save to", dlg_type=0 )

share_string_list = share_string.split( "/" )
remote_name = share_string_list[ 2 ]
remote_ip = nmb.NetBIOS().gethostbyname( remote_name )[ 0 ].get_ip()
remote_share = share_string_list[ 3 ]
remote_username = "Guest"
remote_password = ""

remote_object = smb.SMB( remote_name, remote_ip )
if ( remote_object.is_login_required() ):
    remote_object.login( remote_username, remote_password )

# copy the file using pysamba
file_object = open( filename, "rb")
remote_object.stor_file( remote_share, "/".join( share_string_list[ 4 : ] ) + os.path.basename( filename ), file_object.read, password=remote_password, timeout=20 )
file_object.close()
    
# using httpapi works with large files
#xbmc.executehttpapi("FileCopy(%s,%s)" % ( filename, share_string + os.path.basename( filename ), ) )


I can use the httpapi, but it just bothered me that pysamba failed.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#2
I've transfered files in excesses of 50mb using smb & nmb samba libraries without problem (in my DVDProfiler script).
Retired from Add-on dev
Reply
#3
sorry, on re-reading your code, it seems your sending from xbox to PC (stor_file), my success was in fetching large files (retr_file)
Retired from Add-on dev
Reply
#4
mybe a dumb question:

why did you set timeout = 20 Huh
mybe the file is not completed tranferred in 20 sec
Reply
#5
IIRC, if i didn't set a timeout it just froze, but it still only copied 64k or something like that.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#6
you dont have to specify password and timeout

mybe this working;

remote_object.stor_file( remote_share, "/".join( share_string_list[ 4 : ] ) + os.path.basename( filename ), file_object.read)
Reply
#7
What is this pysamba, can i stream from xbox to pc with it?
Reply

Logout Mark Read Team Forum Stats Members Help
using pysamba library timeouts with large files0