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