]> code.communitydata.science - covid19.git/blob - wikipedia/scripts/digobs.py
Merge pull request #15 from aaronshaw/master
[covid19.git] / wikipedia / scripts / digobs.py
1 #!/usr/bin/env python3
2
3 import sys
4 import subprocess
5 import logging
6
7 def git_hash(short=False):
8     if short:
9         return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode().strip()
10     else:
11         subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode().strip()
12
13 def get_loglevel(arg_loglevel):
14     loglevel_mapping = { 'debug' : logging.DEBUG,
15                          'info' : logging.INFO,
16                          'warning' : logging.WARNING,
17                          'error' : logging.ERROR,
18                          'critical' : logging.CRITICAL }
19
20     if arg_loglevel in loglevel_mapping:
21         loglevel = loglevel_mapping[arg_loglevel]
22         return loglevel
23     else:
24         print("Choose a valid log level: debug, info, warning, error, or critical", file=sys.stderr)
25         return logging.INFO
26
27

Community Data Science Collective || Want to submit a patch?