def connectionMade(self): sockFD = self.transport.fileno() childFDs = {0: sockFD, 1: sockFD} if self.factory.stderrFile: childFDs[2] = self.factory.stderrFile.fileno() # processes run by inetd expect blocking sockets # FIXME: maybe this should be done in process.py? are other uses of # Process possibly affected by this? fdesc.setBlocking(sockFD) if childFDs.has_key(2): fdesc.setBlocking(childFDs[2]) service = self.factory.service uid = service.user gid = service.group # don't tell Process to change our UID/GID if it's what we # already are if uid == os.getuid(): uid = None if gid == os.getgid(): gid = None process.Process(None, service.program, service.programArgs, os.environ, None, None, uid, gid, childFDs) reactor.removeReader(self.transport) reactor.removeWriter(self.transport)
def spawnProcess(self, processProtocol, executable, args=(), env={}, path=None, uid=None, gid=None, usePTY=0, childFDs=None): args, env = self._checkProcessArgs(args, env) if platformType == 'posix': if usePTY: if childFDs is not None: raise ValueError("Using childFDs is not supported with usePTY=True.") return process.PTYProcess(self, executable, args, env, path, processProtocol, uid, gid, usePTY) else: return process.Process(self, executable, args, env, path, processProtocol, uid, gid, childFDs) elif platformType == "win32": if uid is not None: raise ValueError("Setting UID is unsupported on this platform.") if gid is not None: raise ValueError("Setting GID is unsupported on this platform.") if usePTY: raise ValueError("The usePTY parameter is not supported on Windows.") if childFDs: raise ValueError("Customizing childFDs is not supported on Windows.") if win32process: from twisted.internet._dumbwin32proc import Process return Process(self, processProtocol, executable, args, env, path) else: raise NotImplementedError( "spawnProcess not available since pywin32 is not installed.") else: raise NotImplementedError( "spawnProcess only available on Windows or POSIX.")
def generate(reactor, n=1): assert n > 0 d = defer.Deferred() proto = ReadPassword(d, n) process.Process(reactor, "pwgen", ("pwgen", "-cn1", "-N", "%d" % n), {}, None, proto) return d
def generate(reactor, n=1): assert n>0 d=defer.Deferred() proto=ReadPassword(d, n) process.Process(reactor, 'pwgen', ('pwgen', '-cn1', '-N', '%d'%n), {}, None, proto) return d