7 from optparse import OptionParser
11 XMLRPC_SERVER="https://boot.planet-lab.org/PLCAPI/"
12 def parse_bool(option, opt_str, value, parser):
13 if opt_str in ["--debug"]:
14 parser.values.debug = int(int(value))
15 elif opt_str in ["--mail"]:
16 parser.values.mail = int(int(value))
17 elif opt_str in ["--bcc"]:
18 parser.values.bcc = int(int(value))
19 elif opt_str in ["--policysavedb"]:
20 parser.values.policysavedb = int(int(value))
21 elif opt_str in ["--squeeze"]:
22 parser.values.squeeze = int(int(value))
30 email="soltesz@cs.utk.edu"
37 def __init__(self, parser=None):
38 if os.path.exists(self.__file): # file exists, read that.
39 f = open(self.__file, 'r')
41 self.__dict__.update(o)
45 self.parser = OptionParser()
49 self.parser.set_defaults(debug = self.debug,
55 squeeze = self.squeeze,
56 policysavedb = self.policysavedb)
58 self.parser.add_option("", "--debug", dest="debug",
59 help="Enable debugging",
64 self.parser.add_option("", "--mail", dest="mail",
65 help="Enable sending email",
70 self.parser.add_option("", "--bcc", dest="bcc",
71 help="Include BCC to user",
76 self.parser.add_option("", "--squeeze", dest="squeeze",
77 help="Squeeze sites or not",
82 self.parser.add_option("", "--policysavedb", dest="policysavedb",
83 help="Save the policy event database after a run",
88 self.parser.add_option("", "--checkopt", dest="checkopt",
90 help="print current options")
91 self.parser.add_option("", "--run", dest="run",
93 help="Perform monitor or print configs")
94 self.parser.add_option("", "--email", dest="email",
95 help="Specify an email address to use for mail when "+\
96 "debug is enabled or for bcc when it is not")
98 # config_command is needed to keep subsequent loads of config() from
99 # trying to parse the arguments that have already been parsed by
101 if parser == None and config_command:
102 print "calling parse_args"
105 def parse_args(self):
106 #print "self: %s" % self
108 #print traceback.print_stack()
109 #print "Ccalling parse_args"
110 (options, args) = self.parser.parse_args()
111 #for o in options.__dict__:
112 # print "optin: %s == %s" % (o, options.__dict__[o])
113 self.__dict__.update(options.__dict__)
114 self.__dict__['args'] = args
118 # print "\nAdd --run to actually perform the command"
121 def getListFromFile(self, file):
129 def print_values(self):
131 for key in self.__dict__.keys():
132 if key not in exclude:
133 print "%20s == %s" % (key, self.__dict__[key])
135 def save(self, options=None):
136 f = open(self.__file, 'w')
138 o = {'debug': self.debug,
142 'squeeze':self.squeeze,
143 'policysavedb':self.policysavedb}
152 self.parser.print_help()
156 """ Start threads, do some housekeeping, then daemonize. """
158 global config_command
159 config_command = True
160 config = __main__.config()
163 print "acalling parse_args"
166 except Exception, err:
167 print "Error: %s " % err
174 if __name__ == '__main__':