All pastes #583653 Raw Edit

Mine

public python v1 · immutable
·published 2007-06-22 13:47 UTC
rendered paste body
import os, reclass diskinfo:        def __init__(self):                self.df_content =  os.popen('df').read().strip().split('\n')        def getStat (self, drive=None, mpoint=None, section=None):                found = False                for item in self.df_content[1:]:                        data = re.split('\s+', item)                        if (drive != None and  data[0].strip() == drive.strip()) or (mpoint != None and data[5].strip() == mpoint.strip()):                                found = True                                if section == None:                                        return data                                else:                                        if section == 'd': #drive                                                return data[0]                                        elif section == 'a': #avaliable space (in bytes)                                                return data[1]                                        elif section == 'u': #used space (in bytes)                                                return data[2]                                        elif section == 'f': #avaliable                                                return data[3]                                        elif section == 'p': #free in percents                                                return data[4]                                        elif section == 'm': #mount point                                                return data[5]                return found        def toHuman(digit):                if digit < 1024: #kbytes                        return str(digit) + " k"                elif digit >= 1024 and digit < (1024 ** 2):                        return str(round(float(digit) / 1024, 2)) + " M"                elif digit >= (1024 ** 2) :                        return str(round(float(digit) / (1024 **2),2) ) + " G"        def getAll(self):                return self.df_content#another file:import diskadm, os, timeda = diskadm.diskinfoprint da.getStat(mountp=mpf, section='p')