-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstencil.py
More file actions
executable file
·60 lines (38 loc) · 1.03 KB
/
stencil.py
File metadata and controls
executable file
·60 lines (38 loc) · 1.03 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python -tt
import sys,getopt
import logging
logger = logging.getLogger('stencil')
hdlr = logging.StreamHandler(sys.stdout)
#hdlr = logging.FileHandler('stencil.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.INFO) #logging.DEBUG
def help():
print " Usage: stencil.py --help "
def main(argv):
# make sure command line arguments are valid
try:
options, args = getopt.getopt(
argv,
'hv',
[
'help',
'verbose'
])
except getopt.GetoptError:
logging.fatal("Bad options!")
help()
sys.exit(2)
# handle command line arugments
for opt, arg in options:
if opt in ('-h', '--help'):
help()
sys.exit(2)
elif opt in ('-v', '--verbose'):
logger.setLevel(logging.DEBUG)
###################################
# main code starts here
###################################
if __name__ == "__main__":
main(sys.argv[1:])