summaryrefslogtreecommitdiffstats
path: root/code/templates/script.py
blob: d1ba416d1e5b642d4f5eac5bd746ad39e7d0c60f (plain)
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
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python

import sys
import argparse
import logging

log = logging.getLogger(__name__)


def run():
    log.info('This is an INFO level message.')
    log.debug('This is a DEBUG level message.')
    log.warn('This is a WARN level message.')

def main():

    global log
    parser = argparse.ArgumentParser()
    parser.add_argument("-v", "--verbose", 
        default=False,
        help="Show more debugging statements", 
        action="store_true")
    parser.add_argument("commands", nargs='*')

    options = parser.parse_args()
    args = options.commands

    if len(args) != 0:
        parser.error("Incorrect number of arguments")

    log = logging.getLogger()
    log.addHandler(logging.StreamHandler())
    if options.verbose:
        log.setLevel(logging.DEBUG)
    else:
        log.setLevel(logging.INFO)

    run()

if __name__ == '__main__':
    main()