Enhanced setbg
[clearscm.git] / bin / test.py
1 #!/usr/bin/python
2
3 import sys, getopt
4
5 security_logfile = '/var/log/auth.log'
6 verbose = 0
7 debug   = 0
8 update  = 0
9 email   = 0
10
11 def Usage (msg = ''):
12   if msg != '':
13     print msg
14     
15   print """
16 Usage: bice.py [-u|sage] [-v|erbose] [-d|ebug] [-nou|pdate] [-nom|ail]
17                [-f|ilename <filename> ]
18
19 Where:
20   -u|sage     Print this usage
21   -v|erbose:  Verbose mode (Default: -verbose)
22   -nou|pdate: Don't update security logfile file (Default: -update)
23   -nom|ail:   Don't send emails (Default: -mail)
24   -f|ilename: Open alternate messages file (Default: /var/log/auth.log)
25   """
26 def mainold (argv):
27   global verbose, debug, update, email, security_logfile
28   
29   print "in main"
30   
31   try:
32     #opts, args = getopt.getopt (argv, "vd", ['verbose', 'debug', 'usage', 'update', 'mail', 'file='])
33     opts, args = getopt.getopt (argv, "hi:o:", ["ifile=","ofile="])
34   except getopt.GetoptError:
35     Usage;
36     sys.exit (1);
37     
38   for opt, arg in opts:
39     print 'opt: ', opt
40     print 'arg:',  arg
41      
42     if opt in ['-v', '-verbose']:
43       verbose = 1
44     elif opt in ['-d', '-debug']:
45       debug = 1
46     elif opt in ['-u', '-usage']:
47       Usage 
48     elif opt in ['-update']:
49       update = 1
50     elif opt in ['-m', '-mail']:
51       email = 1
52     elif opt in ['-f', '-file']:
53       security_logfile = arg
54   
55   print 'Args:'
56   print 'verbose', verbose
57   print 'debug',   debug
58   print 'update',  update
59   print 'email',   email
60   print 'file',    security_logfile
61   
62 def main(argv):
63   global verbose, debug, update, email, security_logfile
64
65   inputfile = ''
66   outputfile = ''
67
68   try:
69     opts, args = getopt.getopt(argv,"hvi:o:",["verbose", "ifile=","ofile="])
70   except getopt.GetoptError:
71     Usage ()
72     print 'test.py -i <inputfile> -o <outputfile>'
73     sys.exit(2)
74     
75   for opt, arg in opts:
76     print 'opt: ', opt
77     print 'arg: ', arg
78     if opt in ['-v', '--verbose']:
79       verbose = 1
80     elif opt in ['-u', '-usage']:
81       Usage ()
82     elif opt == '-h':
83       print 'test.py -i <inputfile> -o <outputfile>'
84       sys.exit()
85     elif opt in ("-i", "--ifile"):
86       inputfile = arg
87     elif opt in ("-o", "--ofile"):
88       outputfile = arg
89
90   print 'Args:'
91   print 'verbose', verbose
92   print 'debug',   debug
93   print 'update',  update
94   print 'email',   email
95   print 'file',    security_logfile
96
97 if __name__ == "__main__":
98    main (sys.argv[1:])