7 from optparse import OptionParser
8 from parser import parse_bool
13 email="soltesz@cs.utk.edu"
19 config_command = False
21 def updatemodule(module, cf):
22 module.__dict__.update(cf.__dict__)
28 email="soltesz@cs.utk.edu"
35 def __init__(self, parser=None):
36 if os.path.exists(self.__file): # file exists, read that.
37 f = open(self.__file, 'r')
39 self.__dict__.update(o)
43 self.parser = OptionParser()
47 self.parser.set_defaults(debug = self.debug,
53 squeeze = self.squeeze,
54 policysavedb = self.policysavedb)
56 self.parser.add_option("", "--debug", dest="debug",
57 help="Enable debugging",
62 self.parser.add_option("", "--mail", dest="mail",
63 help="Enable sending email",
68 self.parser.add_option("", "--bcc", dest="bcc",
69 help="Include BCC to user",
74 self.parser.add_option("", "--squeeze", dest="squeeze",
75 help="Squeeze sites or not",
80 self.parser.add_option("", "--policysavedb", dest="policysavedb",
81 help="Save the policy event database after a run",
86 self.parser.add_option("", "--checkopt", dest="checkopt",
88 help="print current options")
89 self.parser.add_option("", "--run", dest="run",
91 help="Perform monitor or print configs")
92 self.parser.add_option("", "--email", dest="email",
93 help="Specify an email address to use for mail when "+\
94 "debug is enabled or for bcc when it is not")
96 # config_command is needed to keep subsequent loads of config() from
97 # trying to parse the arguments that have already been parsed by
99 if parser == None and config_command:
100 print "calling parse_args"
103 def parse_args(self):
104 #print "self: %s" % self
106 #print traceback.print_stack()
107 #print "Ccalling parse_args"
108 (options, args) = self.parser.parse_args()
109 #for o in options.__dict__:
110 # print "optin: %s == %s" % (o, options.__dict__[o])
111 self.__dict__.update(options.__dict__)
112 self.__dict__['args'] = args
116 # print "\nAdd --run to actually perform the command"
119 def getListFromFile(self, file):
127 def print_values(self):
129 for key in self.__dict__.keys():
130 if key not in exclude:
131 print "%20s == %s" % (key, self.__dict__[key])
133 def save(self, options=None):
134 f = open(self.__file, 'w')
136 o = {'debug': self.debug,
140 'squeeze':self.squeeze,
141 'policysavedb':self.policysavedb}
150 self.parser.print_help()
154 """ Start threads, do some housekeeping, then daemonize. """
156 global config_command
157 config_command = True
158 config = __main__.config()
161 print "acalling parse_args"
164 except Exception, err:
165 print "Error: %s " % err
172 if __name__ == '__main__':