summaryrefslogtreecommitdiffstats
path: root/code/templates/script.py
blob: 467a1ce734e6c21e1aa6ce9ebc9bd5a2c09d2016 (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 optparse
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 = optparse.OptionParser(usage=
        "usage: %prog <environment.ini> [options]\n"
        "%prog --help for more info."
    )
    parser.add_option("-v", "--verbose", 
        default=False,
        help="Show more debugging statements", 
        action="store_true")

    (options, args) = parser.parse_args()

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

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

    run()

if __name__ == '__main__':
    main()