summaryrefslogtreecommitdiffstats
path: root/code/templates/script.py
blob: 05a9e03911fc7cd38e502049ff66b63bb0e1852d (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
42
43
44
45
46
#!/usr/bin/env python
"""
..
    Copyright: None
    License: Public Domain
    Author: You
    Date: January 1970

This is a template script. Do as you will!
"""

from __future__ import print_function
import sys
import argparse
import logging as log


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():
    parser = argparse.ArgumentParser(
        description="A template script",
        usage="%(prog)s <commands> [arguments]")
    parser.add_argument("-v", "--verbose",
        action="count",
        help="Show more debugging statements")
    parser.add_argument("commands", nargs='*')

    args = parser.parse_args()

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

    if args.verbose > 0:
        log.basicConfig(format="%(levelname)s: %(message)s", level=log.DEBUG)
    else:
        log.basicConfig(format="%(levelname)s: %(message)s")

    run()

if __name__ == '__main__':
    main()