def main(argv): args = docopt(__doc__, argv=argv) row_types = { 0: 'green', 1: 'blue', 2: 'red', 9: 'brown', } if args['--green-rows']: tasks = get_tasks(task_type='green') elif args['--blue-rows']: tasks = get_tasks(task_type='blue') elif args['--red-rows']: tasks = get_tasks(task_type='red') else: tasks = c.tasks for t in tasks: task_info = [ t.identifier, t.task_id, t.server, t.time, t.command, row_types[t.row_type], ] if args['--verbose']: # parse task args and append to task_info list. targs = '\t'.join( ['{0}={1}'.format(k, v) for (k, v) in t.args.items()]) task_info += [t.submitter, targs] stdout.write('\t'.join([str(x) for x in task_info]) + '\n')
def main(argv): args = docopt(__doc__, argv=argv) row_types = { -1: 'done', 0: 'green', 1: 'blue', 2: 'red', 9: 'brown', } if args['<identifier>']: tasks = get_tasks(identifier=args['<identifier>']) elif args['--green-rows']: tasks = get_tasks(task_type='green') elif args['--blue-rows']: tasks = get_tasks(task_type='blue') elif args['--red-rows']: tasks = get_tasks(task_type='red') else: tasks = get_tasks() for t in tasks: task_info = [ t.identifier, t.task_id, t.server, t.time, t.command, row_types[t.row_type], ] if args['--verbose']: # parse task args and append to task_info list. targs = '\t'.join(['{0}={1}'.format(k, v) for (k, v) in t.args.items()]) task_info += [t.submitter, targs] sys.stdout.write('\t'.join([str(x) for x in task_info]) + '\n')
def main(argv): args = docopt(__doc__, argv=argv) params = get_args_dict(args['--parameter']) row_types = { -1: 'done', 0: 'green', 1: 'blue', 2: 'red', 9: 'brown', } task_type = None if args['--green-rows']: task_type = 'green' elif args['--blue-rows']: task_type = 'blue' elif args['--red-rows']: task_type = 'red' try: if args['<identifier>']: tasks = get_tasks(identifier=args['<identifier>'], task_type=task_type, params=params) elif args['--get-task-log']: task = get_tasks(task_ids=args['--get-task-log'], params=params) if task: log = task[0].task_log() sys.stdout.write(log) else: sys.stderr.write('error retrieving task-log for {0}\n'.format( args['--get-task-log'])) sys.exit(1) sys.exit(0) elif args['--task']: tasks = get_tasks(task_ids=args['--task'], params=params) else: tasks = get_tasks(task_type=task_type, params=params) for t in tasks: task_info = [ t.identifier, t.task_id, t.server, t.time, t.command, row_types[t.row_type], ] if args['--verbose']: # parse task args and append to task_info list. targs = '\t'.join( ['{0}={1}'.format(k, v) for (k, v) in t.args.items()]) task_info += [t.submitter, targs] sys.stdout.write('\t'.join([str(x) for x in task_info]) + '\n') except NameError as exc: sys.stderr.write('error: {0}'.format(exc.message)) sys.exit(1)
def main(argv): args = docopt(__doc__, argv=argv) params = get_args_dict(args['--parameter']) row_types = { -1: 'done', 0: 'green', 1: 'blue', 2: 'red', 9: 'brown', } task_type = None if args['--green-rows']: task_type = 'green' elif args['--blue-rows']: task_type = 'blue' elif args['--red-rows']: task_type = 'red' try: if args['<identifier>']: tasks = get_tasks(identifier=args['<identifier>'], task_type=task_type, params=params) elif args['--get-task-log']: task = get_tasks(task_ids=args['--get-task-log'], params=params) if task: log = task[0].task_log() sys.stdout.write(log) else: sys.stderr.write( 'error retrieving task-log for {0}\n'.format(args['--get-task-log']) ) sys.exit(1) sys.exit(0) elif args['--task']: tasks = get_tasks(task_ids=args['--task'], params=params) else: tasks = get_tasks(task_type=task_type, params=params) for t in tasks: task_info = [ t.identifier, t.task_id, t.server, t.time, t.command, row_types[t.row_type], ] if args['--verbose']: # parse task args and append to task_info list. targs = '\t'.join(['{0}={1}'.format(k, v) for (k, v) in t.args.items()]) task_info += [t.submitter, targs] sys.stdout.write('\t'.join([str(x) for x in task_info]) + '\n') except NameError as exc: sys.stderr.write('error: {0}'.format(exc.message)) sys.exit(1)
def update_es_doc(acd, es_id, d_type, doc, items, updates, index): updates['count'] += 1 doc_orig = doc.copy() status = doc['status'] identifier = doc['itemid'] put_count = 0 deriving_found = False for task in internetarchive.get_tasks(identifier): args = task.args if 'derive' == args.get('next_cmd', ''): deriving_found = True break elif 's3-put' == args.get('comment', ''): put_count += 1 if deriving_found: status = 'deriving' updates['deriving'] += 1 elif 1 < put_count: status = 'uploading' updates['uploading'] += 1 item = archivecd.Item(identifier) metadata = item.item.metadata if 0 != len(metadata): if metadata.has_key('ocr'): status = 'finished' updates['finished'] += 1 if not doc.has_key('got_metadata'): doc['got_metadata'] = True doc['collection'] = ";".join(metadata['collection']) doc['boxid'] = metadata.get('boxid', 'unknown') doc['collection-catalog-number'] = metadata.get( 'collection-catalog-number', 'unknown') doc['scanning_center'] = metadata.get('scanningcenter', 'unknown') # also, let's add the scandata stuff sd = scandata.ScanData(item=item, logger=acd.logger) if None != sd.data: data = sd.data doc['scan_wait_time'] = sd.get_scan_bias() doc['first_template'] = sd.get_first_scan_template() doc['discs'] = len(data['technical_metadata']['discs']) tab_data = data['analytics']['tabs'] for key in tab_data: doc[key + '_time_focused'] = tab_data[key]['total_time_focused'] items += get_items_for_track_rip_speeds(doc, sd, index) doc['status'] = status if doc != doc_orig: acd.logger.debug("updated '%s' to %s" % (identifier, status)) items.append({ '_type': d_type, '_index': index, '_id': es_id, '_op_type': 'update', 'doc': doc })
def main(argv, session): args = docopt(__doc__, argv=argv) params = get_args_dict(args["--parameter"]) row_types = {-1: "done", 0: "green", 1: "blue", 2: "red", 9: "brown"} task_type = None if args["--green-rows"]: task_type = "green" elif args["--blue-rows"]: task_type = "blue" elif args["--red-rows"]: task_type = "red" try: if args["<identifier>"]: tasks = get_tasks(identifier=args["<identifier>"], task_type=task_type, params=params) elif args["--get-task-log"]: task = get_tasks(task_ids=args["--get-task-log"], params=params) if task: log = task[0].task_log() sys.stdout.write(log) else: sys.stderr.write("error retrieving task-log for {0}\n".format(args["--get-task-log"])) sys.exit(1) sys.exit(0) elif args["--task"]: tasks = get_tasks(task_ids=args["--task"], params=params) else: tasks = get_tasks(task_type=task_type, params=params) for t in tasks: task_info = [t.identifier, t.task_id, t.server, t.time, t.command, row_types[t.row_type]] if args["--verbose"]: # parse task args and append to task_info list. targs = "\t".join(["{0}={1}".format(k, v) for (k, v) in t.args.items()]) task_info += [t.submitter, targs] sys.stdout.write("\t".join([str(x) for x in task_info]) + "\n") except NameError as exc: sys.stderr.write("error: {0}".format(exc.message)) sys.exit(1)