parser.add_argument('start', type=parse, nargs='?', default=datetime.now(), help='Start (YYYY-mm-dd)') parser.add_argument('end', type=parse, nargs='?', default=False, help='End (YYYY-mm-dd)') parser.add_argument('-p', '--processes', type=int, default=1, help='number of processes') parser.add_argument('-d', '--directory', type=str, help='Directory to read data', default=cfg.pickles_dir) args = parser.parse_args() start = args.start end = args.end if not end: end = start for date in daterange(start, end): update_acct(date, rerun=False) update_metrics(date, args.directory, args.processes, rerun=False)
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "job_pickles_lock"), "w") as fd: try: flock(fd, LOCK_EX | LOCK_NB) except IOError: print("job_pickles is already running") sys.exit() parser = argparse.ArgumentParser(description='Run pickler for jobs') parser.add_argument('start', type = parse, nargs='?', default = datetime.now(), help = 'Start (YYYY-mm-dd)') parser.add_argument('end', type = parse, nargs='?', default = False, help = 'End (YYYY-mm-dd)') parser.add_argument('-p', '--processes', type = int, default = 1, help = 'number of processes') parser.add_argument('-d', '--directory', type = str, help='Directory to store data', default = cfg.pickles_dir) parser.add_argument('-jobids', help = 'Pickle this list of jobs', type = str, nargs = '+') args = parser.parse_args() start = args.start end = args.end if not end: end = start for date in daterange(start, end): pickler = JobPickles(args.directory, args.processes, args.jobids) pickler.run(date)