def print_worker(self, worker, term): # <state> - file: [====>] 001/100 (xxx%) status = worker.status_data state = status['state'] if state == FetchWorker.STATE_DOWN: percent_complete = ceil((float(status['bytes_received']) / float(status['bytes_total'])) * 100) prefix = '<{state:^11s}> - {file:^20}: '.format( state=status['state'], file=status['name'][:20], seq=status['sequence']) suffix = ' {:>4}/{:>4} ({:>3}%)'.format( bytes2human(status['bytes_received']), bytes2human(status['bytes_total']), int(percent_complete)) bar_len = term.width - len(prefix) - len(suffix) - 2 # 2 for [] bar_count = int(bar_len * (percent_complete / 100)) bars = ('[{0:<' + str(bar_len) + '}]').format('=' * (bar_count - 1) + '>') print prefix + bars + suffix else: print '<{state:^11s}> - Job Startup'.format( state=status['state'], ) return
def start(self, args, config): # If there is no nzbfile, check stdin. with open(args.nzbfile) as fp: parsed = parse_nzb(fp.read()) for file in parsed: print file.subject print file.groups print bytes2human(file.bytes) for segment in file.segments: print " ", bytes2human(segment.bytes), segment.message_id
def start(self, args, config): # If there is no nzbfile, check stdin. with open(args.nzbfile) as fp: parsed = parse_nzb(fp.read()) for file in parsed: print file.subject print file.groups print bytes2human(file.bytes) for segment in file.segments: print ' ', bytes2human(segment.bytes), segment.message_id
def print_worker(self, worker, term): # <state> - file: [====>] 001/100 (xxx%) status = worker.status_data state = status["state"] if state == FetchWorker.STATE_DOWN: percent_complete = ceil((float(status["bytes_received"]) / float(status["bytes_total"])) * 100) prefix = "<{state:^11s}> - {file:^20}: ".format( state=status["state"], file=status["name"][:20], seq=status["sequence"] ) suffix = " {:>4}/{:>4} ({:>3}%)".format( bytes2human(status["bytes_received"]), bytes2human(status["bytes_total"]), int(percent_complete) ) bar_len = term.width - len(prefix) - len(suffix) - 2 # 2 for [] bar_count = int(bar_len * (percent_complete / 100)) bars = ("[{0:<" + str(bar_len) + "}]").format("=" * (bar_count - 1) + ">") print prefix + bars + suffix else: print "<{state:^11s}> - Job Startup".format(state=status["state"]) return