当前位置: 首页>>代码示例>>Python>>正文


Python Popen.__init__方法代码示例

本文整理汇总了Python中subprocess.Popen.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Popen.__init__方法的具体用法?Python Popen.__init__怎么用?Python Popen.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在subprocess.Popen的用法示例。


在下文中一共展示了Popen.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import __init__ [as 别名]
 def __init__(self, args, logger, **kwargs):
     _kwargs = kwargs.copy()
     for fdname in self.fdnames:
         _kwargs[fdname] = PIPE
     Popen.__init__(self, args, **_kwargs)
     self.logger = logger
     self.wrapfds()
开发者ID:whilp,项目名称:prociolog,代码行数:9,代码来源:prociolog.py

示例2: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import __init__ [as 别名]
    def __init__(self, argv, map=None, timeout=None, close_when_done=True,
            stdin=PIPE, stdout=PIPE, stderr=PIPE, preexec_fn=None, bufsize=0, **popen_keyw):
        """Accepts all the same arguments and keywords as `subprocess.Popen`.
        Input or outputs specified as `PIPE` (now the default) for are wrapped
        in an asynchronous pipe dispatcher.

        The timeout is used to create an alarm, which can be cancelled by
        calling `cancel_timeout()`, `communicate()`, `wait()` or `kill()`.
        """
        Observable.__init__(self)
        self._map = map
        # Create the subprocess itself, wrapping preexec_fn in the clear_signals call
        Popen.__init__(self, argv, preexec_fn=lambda: self.clear_signals(preexec_fn),
                stdin=stdin, stdout=stdout, stderr=stderr, **popen_keyw)
        # Set the timeout on the subprocess.  If it fails, ignore the failure.
        try:
            fto = float(timeout)
            self._alarmobj = alarm.alarm(fto, self.kill) if fto > 0 else None
        except:
            self._alarmobj = None
        # Wrap the pipe I/O. Sets the Popen and pipe buffer sizes the same; perhaps not optimal.
        if stdout == PIPE:
            self.stdout = OutputPipeDispatcher(self.stdout, map=map, ignore_broken_pipe=True,
                    universal_newlines=self.universal_newlines, maxdata=bufsize)
            self.stdout.obs_add(self._pipe_event)
        if stderr == PIPE:
            self.stderr = OutputPipeDispatcher(self.stderr, map=map, ignore_broken_pipe=True,
                    universal_newlines=self.universal_newlines, maxdata=bufsize)
            self.stderr.obs_add(self._pipe_event)
        if stdin == PIPE:
            self.stdin = InputPipeDispatcher(self.stdin, map=map, ignore_broken_pipe=True,
                    close_when_done=close_when_done, maxdata=bufsize)
            self.stdin.obs_add(self._pipe_event)
开发者ID:jacob-carrier,项目名称:code,代码行数:35,代码来源:recipe-576957.py

示例3: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import __init__ [as 别名]
 def __init__(self, args, wait_for_traps_listener_port=0, **kwargs):
     ''' Creates child and (optionally) waits for trap listener ready '''
     Popen.__init__(self, args,
                    **{**kwargs, 'stdout': PIPE, 'stderr': PIPE})
     if wait_for_traps_listener_port > 0:
         self.__wait_for_trap_listener(
                                 expected_port=wait_for_traps_listener_port)
开发者ID:eugpermar,项目名称:rb_monitor,代码行数:9,代码来源:mon_test.py

示例4: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import __init__ [as 别名]
    def __init__(self, args, executable=None,
                 stdin=None, stdout=None, stderr=None,
                 cwd=None, env={},
                 time_limit=None, rss_limit=None, vm_limit=None):
        self._time_limit = time_limit
        self._rss_limit = rss_limit
        self._vm_limit = vm_limit

        self.cputime = None
        self.maxrss = 0
        self.maxvm = 0
        self.verdict = None

        Popen.__init__(
            self, args, bufsize=-1, executable=executable,
            stdin=stdin, stdout=stdout, stderr=stderr, close_fds=True,
            preexec_fn=self._preexec_hook, cwd=cwd, env=env)

        _, status = waitpid(self.pid, WUNTRACED)

        assert WIFSTOPPED(status), "cannot start subprocess"

        if WSTOPSIG(status) != SIGTRAP:
            self.kill()
            self.wait()
            assert False, "subprocess stopped unexpectedly"
开发者ID:bhuztez,项目名称:gulag,代码行数:28,代码来源:ptrace.py

示例5: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import __init__ [as 别名]
    def __init__(self, label='bithorded', bithorded=os.environ.get('BITHORDED', 'bithorded'), config={}):
        cmd = ['stdbuf', '-o0', '-e0', bithorded, '-c', '/dev/stdin', '--log.level=TRACE']
        Popen.__init__(self, cmd, stderr=STDOUT, stdout=PIPE, stdin=PIPE)
        self._cleanup = list()
        if hasattr(config, 'setdefault'):
            suffix = (time(), os.getpid())
            server_cfg = config.setdefault('server', {})
            server_cfg.setdefault('tcpPort', 0)
            server_cfg.setdefault('inspectPort', 0)
            server_cfg.setdefault('unixSocket', "bhtest-sock-%d-%d" % suffix)
            self._cleanup.append(lambda: os.unlink(server_cfg['unixSocket']))
            cache_cfg = config.setdefault('cache', {})
            if 'dir' not in cache_cfg:
                from shutil import rmtree
                d = 'bhtest-cache-%d-%d' % suffix
                self._cleanup.append(lambda: rmtree(d, ignore_errors=True))
                os.mkdir(d)
                cache_cfg['dir'] = d

        self.buffer = LineBuffer(label, self.stdout)
        self.config = config
        self.label = label
        self.started = False

        self._run()
开发者ID:rawler,项目名称:bithorde,代码行数:27,代码来源:bithordetest.py

示例6: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import __init__ [as 别名]
 def __init__(self, args, ready=None, timeout=30, skip_valgrind=False, **kwargs):
     """Start an example process"""
     args = list(args)
     if platform.system() == "Windows":
         args[0] += ".exe"
     self.timeout = timeout
     self.args = args
     self.out = ""
     if not skip_valgrind:
         args = self.env_args + args
     try:
         Popen.__init__(self, args, stdout=PIPE, stderr=STDOUT,
                        universal_newlines=True,  **kwargs)
     except Exception as e:
         raise ProcError(self, str(e))
     # Start reader thread.
     self.pattern = ready
     self.ready = Event()
     # Help with Python 2.5, 2.6, 2.7 changes to Event.wait(), Event.is_set
     self.ready_set = False
     self.error = None
     self.thread = Thread(target=self.run_)
     self.thread.daemon = True
     self.thread.start()
     if self.pattern:
         self.wait_ready()
开发者ID:JemDay,项目名称:qpid-proton,代码行数:28,代码来源:example_test.py

示例7: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import __init__ [as 别名]
    def __init__(self, args, stdout=None, iotimeout=None, timeout=None, **kwargs):
        self._output = stdout

        Popen.__init__(self, args, stdout=PIPE, stderr=STDOUT,
                       **kwargs)

        self._iostream = IOStream(self.stdout, self._output, iotimeout, timeout, self.timeout_callback)
        self._iostream.start()
开发者ID:cpcloud,项目名称:binstar-build,代码行数:10,代码来源:buffered_io.py

示例8: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import __init__ [as 别名]
  def __init__(self, hide_stderr=False):
    stderr_file = open('/dev/null','w') if hide_stderr else None
    Popen.__init__(self, ['gdb'],
                   stdin=PIPE, stdout=PIPE, stderr=stderr_file)

    self._buffer = ''
    self.read_until_prompt()
    
    self.cmd('set print elements 0')
    self.cmd('set width 0')
开发者ID:binoyjayan,项目名称:utilities,代码行数:12,代码来源:bt.py

示例9: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import __init__ [as 别名]
 def __init__ (self, *args, **keywords):
     self.time = 0
     self.vmpeak = 0
     self.timeout = False
     self.memout = False
     self.path = args[0]
     Popen.__init__(self, *args, **keywords)
     PROCESS_QUERY_INFORMATION = 0x0400
     PROCESS_VM_READ = 0x0010
     self.hProcess = ctypes.windll.kernel32.OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, False, self.pid)
开发者ID:lovrop,项目名称:mini-grader,代码行数:12,代码来源:windows.py

示例10: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import __init__ [as 别名]
 def __init__(self, command, filename, preexec_fn=_setlimits):
     """Class constructor.
     
     :param command: A command to run, e.g., "python".
     :param filename: A script file to pass to the `command`.
     :param preexec_fn: A function to call in the child process.
     """
     
     self.arg_list = [command, filename]
     Popen.__init__(self, self.arg_list, stdout=PIPE, stdin=PIPE,
             preexec_fn=preexec_fn)
开发者ID:dwyde,项目名称:poolside,代码行数:13,代码来源:kernels.py

示例11: run

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import __init__ [as 别名]
 def run(self):
    Popen.__init__(self, [self.path, '-idle', '-slave', '-quiet']+self.args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
    self.manager = Manager()
    self.defaults = self.manager.dict()
    self._state = Value('i')
    self._state.value = STOPPED
    self.notifier = SelectQueue()
    self.calls = SelectQueue()
    self.results = Queue()
    self.ioworker = IOWorker(self.stdin, self.stdout, self._state, self.notifier, self.calls, self.results)
    self.ioworker.start()
开发者ID:sevra,项目名称:python-mplayer,代码行数:13,代码来源:mplayer.py

示例12: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import __init__ [as 别名]
    def __init__ (self, *args, **keywords):
        self.time = 0
        self.vmpeak = 0
        self.timeout = False
        self.memout = False
        self.path = args[0]

        # Raise stack limit as high as it goes (hopefully unlimited)
        soft, hard = resource.getrlimit(resource.RLIMIT_STACK)
        resource.setrlimit(resource.RLIMIT_STACK, (hard, hard))

        # Now start the process
        Popen.__init__(self, *args, **keywords)
开发者ID:lovrop,项目名称:mini-grader,代码行数:15,代码来源:linux.py

示例13: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import __init__ [as 别名]
    def __init__(self, args, close_fds=False, cwd=None, env=None,
                 deathSignal=0):
        if not isinstance(args, list):
            args = list(args)

        if env is not None and not isinstance(env, list):
            env = list(("=".join(item) for item in env.iteritems()))

        self._deathSignal = int(deathSignal)
        Popen.__init__(self, args,
                       close_fds=close_fds, cwd=cwd, env=env,
                       stdin=PIPE, stdout=PIPE,
                       stderr=PIPE)
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:15,代码来源:__init__.py

示例14: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import __init__ [as 别名]
 def __init__(self, args, ready=None, timeout=30, skip_valgrind=False, **kwargs):
     """Start an example process"""
     args = list(args)
     if platform.system() == "Windows":
         args[0] += ".exe"
     self.timeout = timeout
     self.args = args
     self.out = ""
     if not skip_valgrind:
         args = self.env_args + args
     try:
         Popen.__init__(self, args, stdout=PIPE, stderr=STDOUT, **kwargs)
     except Exception, e:
         raise ProcError(self, str(e))
开发者ID:ShaLei,项目名称:qpid-proton,代码行数:16,代码来源:example_test.py

示例15: run

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import __init__ [as 别名]
	def run(self):
		from subprocess import PIPE
		rout = self.return_stdout
		rerr = self.return_stderr
		Popen.__init__(self,
			self.args,
			stdout=self.custom_stdout or (PIPE if rout else None),
			stderr=PIPE if rerr else None,
			universal_newlines=True
		)
		self.wait()
		if self.returncode != 0: raise CmdError(self)
		if self.return_self: return self
		elif rout and rerr: return self.stdout.read(), self.stderr.read()
		elif rout: return self.stdout.read()
		elif rerr: return self.stderr.read()
开发者ID:szhu,项目名称:sublime-ubuntu-installer,代码行数:18,代码来源:install_sublime.py


注:本文中的subprocess.Popen.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。