elif(not os.path.isdir(input[1])): print "The path: '" + str(input[1]) + "' that you specified doesn't exist." return False else: size = str(input[2]).strip() amount = int(size[:-1]) unit = size[-1:].upper() if("G" != unit and "M" != unit): print "The size of the file can only be in M or G, like 10M, 5G." return False else: statvfs = os.statvfs(os.path.normpath(input[1])) bFree = statvfs.f_frsize * statvfs.f_bavail alloSize = amount * 1024 * 1024 * 1024 if("G" == unit) else amount * 1024 * 1024 if(alloSize / bFree > 0.95): print "The file that you will allocate will occupy more than 95 percents of the given path, this is not allowed." return False else: return True if __name__ == '__main__': if(not CommonFunction.cmd_executable("/usr/bin/fallocate")): print "Cannot find the command 'fallocate' in this operation system." elif(not platform.system() == "Linux"): print "The server is not Linux Server. This script is supposed to be executed on Linux Server only." elif(inputValidation(sys.argv)): bash = BashPexpect("bash-\d.\d[$|#] ") bash.start() bash.allocateFileInTargetPath(sys.argv) bash.close()