Writing files

Posted on Saturday 4 July 2009

  • i just wondered about something.
    is it possible to write files to a share (phyton script)?
    smb://passord@10.0.0.6/f/musikk/


  • i dont think any python script can handle smb yet. you would need that lib though.


  • hello ppl, python newbie here :blush:

    could someone give me a hand with that smb lib? i'm trying to write a random player for video files i have on my pc, but i can't even get the list of shared folders/files. here's my script:

    import xbmc
    import smb

    f = open('q:\\scripts\\filelist.txt','w') # output file

    remote = smb.smb('doghouse', '192.168.7.2')

    f.write(remote.get_server_os()) # just to check if the connection works

    shared = remote.list_shared()

    for d in shared:
    f.write(d.get_name())

    f.close()


    this should get me a list of all shared folders on that machine, but all i'm getting is an empty filelist.txt file. i don't even know whether the connection is working. :help:

    any help would be greatly appreciated! thanks in advance!


  • as for now,i can't seem to be able to find all files and folders on a share either.

    i guess i will need a lib like
    http://miketeo.net/projects/pysmb/
    to be able to do what i'm talking about.
    i tested on my xbox now.it works okey ;)

    do anyone know of a xbmc script using a such script???


  • hi madtw. i got it working.
    but the ipadress and machinename is still requiered in my tests. i will check out your project to see if you have some tricks i don't know of. anyway one thing i found out using this lib is that it does never return over 30 files and folders!
    would be realy nice to have a getdirectory object in the phyonmodule.like the httapi have now. there you can getdirectory of anything xbmc supports.


  • thanks.
    i have played around with the lib, it really works great on xbox!
    the only dumb thing is that i can't resolve the computername by only knowing the ipadressa.

    socket.gethostbyaddr('10.0.0.2')
    will just give the ('10.0.0.2','','10.0.0.2')
    on pc it would give ('nydata','','10.0.0.2')


  • do anyone have a smart way to get the name of the computer by ip?

    socket.gethostbyaddr('10.0.0.2')
    will work at my pc but not at the xbox


  • my python mythtv scripts for xbmc make smb connections to look for files and to copy files. have a look at xbmcmythtv (http://sourceforge.net/projects/xbmcmythtv/) for some examples if you're still stumped. the source file that uses smb connections is mythtvutil.py.

    also, have a look in mythtv.py... the connection and nmbservice classes might be of use as examples.


  • ok, after some more tests i figured out that i need to login, even when the share is not password protected ???

    anyway, i could login with user 'guest' and no password, but now besides the shared folders, list_shared() is returning all of my pc's drive letters plus two other names: admin$ and ipc$ - well, i can get rid of these unwanted entries if i ignore the strings with $, but i just wanted to know if this is normal or if i'm still doing something wrong.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Writing files , Please add it free.
    jack @ July 4, 2009 edit
    Filed under: enart.nnkl.com