def extract(self): file = tarfile.open(self.localPath, 'r:gz') logger.debug('Archive opened') try: file.extractall(os.path.join(os.getcwd(), 'tmp')) file.close() except: logger.error('Extract error.') sys.exit()
def listFiles(rootDir, hidden): returnList = [] total_size = 0 fileList = os.listdir(rootDir) for file in fileList: if file.startswith('.') and hidden==0: continue itempath = os.path.join(rootDir, file) if os.path.isdir(itempath) or os.path.islink(itempath): continue total_size += os.path.getsize(itempath) returnList.append(itempath) logger.debug("Total Size: %d" % total_size) return total_size, returnList
def list(self): widgets = ["Listing directory content... ", Bar('>'), ' ', RotatingMarker(), ' ', ReverseBar('<')] pbar = ProgressBar(widgets=widgets, maxval=100).start() pbar.update(0) time.sleep(0.5) if self.recursive: logger.debug("Listing directory content recursively...") pbar.update(20) time.sleep(1) self.total_size, self.fileList = util.recursiveListFiles(self.dir, self.hidden) else: logger.debug("Listing directory content...") pbar.update(20) time.sleep(1) self.total_size, self.fileList = util.listFiles(self.dir, self.hidden) pbar.update(100) pbar.finish() logger.debug("Supported File Types: " + repr(doctype.__all__)) logger.info("Size of directory - %d" % self.total_size)
try: results = parser.parse_args(args=sys.argv[1:]) ########## PREP ########## if results.info: logger.level = 1 elif results.debug: logger.level = 2 except IOError, msg: parser.error(str(msg)) logger.error(str(msg)) return 1 ########## INIT ########## logger.debug(results) core.init() ########## CONFIG ########## if results.which.startswith('config'): if results.which == 'config.list': conf.listConfig(None) if results.which == 'config.write': conf.writeConfig(results.key, results.value) if results.which == 'config.read': print conf.readConfig(results.key) ########## UPDATE ########## elif results.which == 'update': from relo.core.update import ReloUpdater curVersion = __version__
def curl(url, path): command = "curl -L -# -o '%s' '%s'" % (path, url) logger.debug(command) subprocess.call(command, shell=True)
def load(self): logger.debug("Redis auto loads")
def check(self): logger.debug("check not needed with redis")
def init(self): logger.debug("Connecting to Redis") self.connection = redis.StrictRedis(host='localhost', port=6379, db=12)