Python Development Documentations (outdated)
#16
@alx5962 has your scripting tutorial moved somewhere else ?
#17
i'm not alex5962. he leaved python scene.
it's scripting tutorial was on alexpoet server, but seems to be offline....

anyway, you can get its tutorial on xbmc online manual :
http://manual.xboxmediacenter.de/wakka.p....g&v=vr9
#18
i never found any info on how the get drive free space, so i'm posting this for others who need it. please let me know if there is any better way (i realize some of the code in the ftp part could be done better, but i wrote it when i was first learning, and i'm too lazy to fix it =] )

this code first tries to use the httpapi (available after july 21, 05) and then defaults to getting it via ftp. if you don't want to support older versions, you can modify this to use the httpapi inteface only.

hope this helps someone

ruuk

Quote:# returns number of full megabytes

def free(drive,ip,user,password):
return space(drive,ip,user,password)

ftpmode = false
try:
from xbmc import executehttpapi
except:
ftpmode = true

space = none
if not ftpmode:
def space(drive,ip,user,password):
drives = {'c':'115',
'e':'117',
'f':'118',
'g':'119'}
free = executehttpapi('getsysteminfo(' + drives[drive] + ')')
val = free.split(drive + ': ',1)[1]
val , type = val.split(' ',1)
type = type[:2].upper()
return convert_value(val,type)
else:
def space(drive,ip,user,password):
try:
from ftplib import ftp
ftp = ftp(ip,user,password)
space_line = ftp.retrlines('list', blah)
ftp.quit()
bits = space_line.split(drive + ':\\ ')
last = bits.pop()
final = last.split(' ')
amount = float(final[0])
type_get = final[1]
bits = type_get.split(']')
type = bits[0]
return convert_value(amount,type)
except:
return 0

def blah(line):
pass

def convert_value(val,type):
if type == 'mb':
return int(val)
elif type == 'gb':
return int(float(val) * 1024)
else:
return 0
#19
for what it's worth, my personal website is back up again. thanks to everyone who hosted the files elsewhere while it was down.
For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/

Logout Mark Read Team Forum Stats Members Help
Python Development Documentations (outdated)0