2005-10-12, 12:09
@alx5962 has your scripting tutorial moved somewhere else ?
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