Mercurial > ~darius > hgwebdir.cgi > agl
comparison agl.py @ 15:7fd3dc0516f8
Do some option sanity checking.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Mon, 11 Sep 2017 22:14:37 +0930 |
parents | db4951d2d303 |
children | 201ad77bac40 |
comparison
equal
deleted
inserted
replaced
14:db4951d2d303 | 15:7fd3dc0516f8 |
---|---|
42 dbfn = conf.get('DEFAULT', 'db') | 42 dbfn = conf.get('DEFAULT', 'db') |
43 | 43 |
44 if not args.update and not args.graph: | 44 if not args.update and not args.graph: |
45 parser.error('Nothing to do') | 45 parser.error('Nothing to do') |
46 | 46 |
47 if args.days is not None and args.days < 0: | |
48 parser.error('days must be non-negative') | |
49 | |
47 start = args.start | 50 start = args.start |
48 if start is None: | 51 if start is None: |
49 start = datetime.date.today() | 52 start = datetime.date.today() |
50 start = datetime.datetime(start.year, start.month, start.day) | 53 start = datetime.datetime(start.year, start.month, start.day) |
51 | 54 |
54 | 57 |
55 end = args.end | 58 end = args.end |
56 if end is None: | 59 if end is None: |
57 end = start + datetime.timedelta(days = 1) | 60 end = start + datetime.timedelta(days = 1) |
58 end = datetime.datetime(end.year, end.month, end.day) | 61 end = datetime.datetime(end.year, end.month, end.day) |
62 | |
63 if start >= end: | |
64 parser.error('Start must be before end') | |
59 | 65 |
60 dbh = sqlite3.connect(dbfn, detect_types = sqlite3.PARSE_DECLTYPES) | 66 dbh = sqlite3.connect(dbfn, detect_types = sqlite3.PARSE_DECLTYPES) |
61 cur = dbh.cursor() | 67 cur = dbh.cursor() |
62 if args.update: | 68 if args.update: |
63 date = start | 69 date = start |