Writing files
#1
i just wondered about something.
is it possible to write files to a share (phyton script)?
smb://username:[email protected]/f/musikk/
Reply
#2
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 Wink

do anyone know of a xbmc script using a such scriptHuh
Reply
#3
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
Reply
#4
i dont think any python script can handle smb yet. you would need that lib though.
Reply
#5
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')
Reply
#6
my python mythtv scripts for xbmc make smb connections to look for files and to copy files. have a look at 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.
Reply
#7
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.
Reply
#8
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:

Quote: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!
Reply
#9
ok, after some more tests i figured out that i need to login, even when the share is not password protected Huh

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.
Reply

Logout Mark Read Team Forum Stats Members Help
Writing files0