Calcular uso del disco duro
arrase
arrase en gulcas.org
Lun Oct 9 20:52:55 CEST 2006
Finalmente he resuelto el tema asi, por si alguien le interesa:
class DiskUsage:
""" Clase que representa el uso de la capacidad de una particion """
def __init__ (self,partiton=None):
# Si no se define una particion se produce una excepcion
if partiton is None:
raise ValueError,'partiton is None'
# Valores que representan el uso del disco
self.fs = partiton
self.kb = 0
self.used = 0
self.available = 0
self.percent = 0
self.mountPoint = None
# Capturamos los datos con 'df'
self.parseDf()
def parseDf(self):
# Ejecutamos 'df'
fh = os.popen ('df -k -P '+self.fs)
# Parseamos la salida de 'df'
while 1 :
line = fh.readline ()
if not line :
break
if line[0] == 'F' :
continue
line = line[:-1]
lineTuple = line.split()
try :
self.kb = lineTuple[1]
self.used = lineTuple[2]
self.available = lineTuple[3]
self.percent = lineTuple[4]
self.mountPoint = lineTuple[5]
except AttributeError :
print "Fallo al obtener la salida de 'df'"
--
<arrase en gulcas.org><http://arrase.no-ip.org><www.gulcas.org>
<Gnupg Keys: http://arrase.no-ip.org/pubkey.txt>
print "".join(map(lambda numChar:filter(lambda x:(x<"0") or \
(x>"9"),numChar),["0"+chr(104)+"0","1"+chr(111)+"1","2"+chr(108)+"2", \
"3"+chr(97)+"3","4"+chr(32)+"4","5"+chr(109)+"5","6"+chr(117)+"6", \
"7"+chr(110)+"7","8"+chr(100)+"8","9"+chr(111)+"9"]))
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-es/attachments/20061009/429167aa/attachment.pgp>
------------ próxima parte ------------
_______________________________________________
Python-es mailing list
Python-es en aditel.org
http://listas.aditel.org/listinfo/python-es
Más información sobre la lista de distribución Python-es