~yerinalexey/pcrond

ref: cf699d50cc90d3569245cbb453b48ff7a9818e40 pcrond/scripts/pcrond -rwxr-xr-x 840 bytes
cf699d50 — Alexey Yerin refactor: remove default Scheduler instance 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python

VERSION = "1.0"

def parse_args():
    import argparse
    import path
    import os

    default_crontab = path.join(os.environ["HOME"], ".local/crontab")

    parser = argparse.ArgumentParser(description='Launch a crond-like daemon in userspace.')
    parser.add_argument('-r', '--crontabfile',
                        help='the crontab file (default ~/.local/crontab)',
                        default=default_crontab)
    parser.add_argument('-v', '--version', action='store_true', help='print version then exit')
    args = parser.parse_args()

    return args

if __name__ == "__main__":
    args = parse_args()
    if args.version:
        print(VERSION)
        exit(0)

    from pcrond import Scheduler

    scheduler = Scheduler()
    scheduler.load_crontab_file(args.crontabfile)
    scheduler.main_loop()