def __init__(self, app, cfg, name = None): self._app = app self._process = None self._name = name if self._name is None: self._name = self._app.osVersion() self._cfg = cfg self._delay = float(cfg.get('delay', '5')) # Special logger for this monitor self.log = getLogger(name) self.log.addHandler(logging.stdout()) self.log.addHandler(logging.file_handler()) self.log.setLevel(logging.level)
def initialize(args): """ Parse the command line options and return the values in the config file. This will remove the Ice runtime arguments if any exist. The Ice runtime arguments will not be returned, but discarded. If you need the Ice runtime arguments, you should initialize the runtime before calling this function (typically done automatically by C{Ice.Application}. This will add the log files for the stream handler and the file handler to the logger. """ if args is None: args = sys.argv[:] # discard Ice command line arguments Ice.createProperties(args) parser = OptionParser( usage="""Usage: %s <tool...> [options] Tools: ripper\t\truns the ripper testgenerator\t\truns the test generator replayer\t\truns the replayer""" % os.path.basename(args[0]) ) parser.add_option( "-c", "--config", dest="configfile", default="guitar.cfg", help="config file path", metavar="FILE" ) (options, args) = parser.parse_args(args) # add logging handlers to the global logger if not os.path.exists("logs"): os.mkdir("logs") log = logging.log log.addHandler(logging.stdout()) log.addHandler(logging.file_handler()) return config.load(options.configfile)