def checkDiskSpace(self): bytes = FileUtils.getFreeDiskSpace(self.working_dir) logging.info(" ========> Analysis %20s checked disk space for %s Free space (bytes) %s Needed %s"%(self.name,self.working_dir,bytes,self.minimum_space_needed)) if self.minimum_space_needed and bytes < self.minimum_space_needed: str = "Not enough disk space needed in %s. Needs %s, available %s"%(self.working_dir,self.minimum_space_needed,bytes) logging.info(" ========> Analysis %20s %s"%(self.name,str)) raise Exception(str) elif bytes < 10000000: str = "Not enough disk space needed in %s. Needs %s, available %s"%(self.working_dir,self.minimum_space_needed,bytes) logging.info(" ========> Analysis %20s %s"%(self.name,str)) raise Exception(str) bytes = FileUtils.getFreeDiskSpace(self.output_dir) logging.info(" ========> Analysis %20s checked disk space for %s Free space (bytes) %s Needed %s"%(self.name,self.output_dir,bytes,self.minimum_space_needed)) if self.minimum_space_needed and bytes < self.minimum_space_needed: str = "Not enough disk space needed in %s. Needs %s, available %s"%(self.output_dir,self.minimum_space_needed,bytes) logging.info(" ========> Analysis %20s %s"%(self.name,str)) raise Exception(str) elif bytes < 10000000: str = "Not enough disk space needed in %s. Needs %s, available %s"%(self.output_dir,self.minimum_space_needed,bytes) logging.info(" ========> Analysis %20s %s"%(self.name,str)) raise Exception(str)
def checkDiskSpace(anaobj): print anaobj.currentstatus print anaobj.working_dir bytes = FileUtils.getFreeDiskSpace(anaobj.working_dir) logging.info(" ========> Analysis %20s checked disk space for %s Free space (bytes) %s Needed %s"%(anaobj.name,anaobj.working_dir,bytes,anaobj.minimum_space_needed)) if anaobj.minimum_space_needed and bytes < anaobj.minimum_space_needed: str = "Not enough disk space needed in %s. Needs %s, available %s"%(anaobj.working_dir,anaobj.minimum_space_needed,bytes) logging.info(" ========> Analysis %20s %s"%(anaobj.name,str)) raise Exception(str) elif bytes < 10000000: str = "Not enough disk space needed in %s. Needs %s, available %s"%(anaobj.working_dir,anaobj.minimum_space_needed,bytes) logging.info(" ========> Analysis %20s %s"%(anaobj.name,str)) raise Exception(str) bytes = FileUtils.getFreeDiskSpace(anaobj.output_dir) logging.info(" ========> Analysis %20s checked disk space for %s Free space (bytes) %s Needed %s"%(anaobj.name,anaobj.output_dir,bytes,anaobj.minimum_space_needed)) if anaobj.minimum_space_needed and bytes < anaobj.minimum_space_needed: str = "Not enough disk space needed in %s. Needs %s, available %s"%(anaobj.output_dir,anaobj.minimum_space_needed,bytes) logging.info(" ========> Analysis %20s %s"%(anaobj.name,str)) raise Exception(str) elif bytes < 10000000: str = "Not enough disk space needed in %s. Needs %s, available %s"%(anaobj.output_dir,anaobj.minimum_space_needed,bytes) logging.info(" ========> Analysis %20s %s"%(anaobj.name,str)) raise Exception(str)
def testGetFreeDiskSpace(self): """Check we can find the free disk space for our working directory""" out = FileUtils.getFreeDiskSpace("/tmp/") print " Bytes free are %d" % out self.assertTrue(out > 0)