def __init__(self): ZDOptions.__init__(self) self.add("program", "runner.program", "p:", "program=", handler=string_list) self.add("backofflimit", "runner.backoff_limit", "b:", "backoff-limit=", int, default=10) self.add("daemon", "runner.daemon", "d", "daemon", flag=1, default=1) self.add("forever", "runner.forever", "f", "forever", flag=1, default=0) self.add("hang_around", "runner.hang_around", default=0) self.add("interactive", None, "i", "interactive", flag=1) self.add("default_to_interactive", "runner.default_to_interactive", default=1) self.add("logfile", None, "l:", "logfile=") self.add("user", "runner.user", "u:", "user="******"prompt", "runner.prompt", default="zopectl>") self.add("umask", "runner.umask", "m:", "umask=") self.add("sockname", "runner.socket_name", "s:", "socket-name=", existing_dirpath, default=None)
def __init__(self): ZDOptions.__init__(self) self.add("opt", "opt", "o:", "opt=", default=42, handler=int, env="OPT")
def load_configfile(self): if getattr(self, "configtext", None): self.configfile = tempfile.mktemp() f = open(self.configfile, 'w') f.write(self.configtext) f.close() try: ZDOptions.load_configfile(self) finally: os.unlink(self.configfile) else: ZDOptions.load_configfile(self)
def realize(self, *a, **k): ZDOptions.realize(self, *a, **k) nunnamed = [s for s in self.storages if s.name is None] if nunnamed: if len(nunnamed) > 1: return self.usage("No more than one storage may be unnamed.") if [s for s in self.storages if s.name == "1"]: return self.usage("Can't have an unnamed storage and a storage named 1.") for s in self.storages: if s.name is None: s.name = "1" break
def realize(self, *a, **k): ZDOptions.realize(self, *a, **k) nunnamed = [s for s in self.storages if s.name is None] if nunnamed: if len(nunnamed) > 1: return self.usage("No more than one storage may be unnamed.") if [s for s in self.storages if s.name == '1']: return self.usage( "Can't have an unnamed storage and a storage named 1.") for s in self.storages: if s.name is None: s.name = '1' break
def realize(self, *args, **kw): ZDOptions.realize(self, *args, **kw) # Additional checking of user option; set uid and gid if self.user is not None: import pwd try: uid = int(self.user) except ValueError: try: pwrec = pwd.getpwnam(self.user) except KeyError: self.usage("username %r not found" % self.user) uid = pwrec[2] else: try: pwrec = pwd.getpwuid(uid) except KeyError: self.usage("uid %r not found" % self.user) gid = pwrec[3] self.uid = uid self.gid = gid config = self.configroot self.directory = config.instancehome self.clienthome = config.clienthome if self.program: if isinstance(self.program, basestring): self.program = [self.program] elif config.runner and config.runner.program: self.program = config.runner.program else: self.program = [os.path.join(self.directory, "bin", "runzope")] if self.sockname: # set by command line option pass elif config.runner and config.runner.socket_name: self.sockname = config.runner.socket_name else: self.sockname = os.path.join(self.clienthome, "zopectlsock") self.python = os.environ.get('PYTHON', config.python) or sys.executable self.zdrun = os.path.join(os.path.dirname(zdaemon.__file__), "zdrun.py") self.exitcodes = [0, 2] if self.logfile is None and config.eventlog is not None: for handler in config.eventlog.handler_factories: if isinstance(handler, FileHandlerFactory): self.logfile = handler.section.path if self.logfile not in ("STDERR", "STDOUT"): break
def __init__(self): ZDOptions.__init__(self) self.add_zeo_options() self.add("storages", "storages", required="no storages specified; use -f or -C")