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


Python subprocess2.communicate函数代码示例

本文整理汇总了Python中subprocess2.communicate函数的典型用法代码示例。如果您正苦于以下问题:Python communicate函数的具体用法?Python communicate怎么用?Python communicate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_timeout

 def test_timeout(self):
   # It'd be better to not discard stdout.
   out, returncode = subprocess2.communicate(
       self.exe + ['--sleep', '--stdout'],
       timeout=0.01,
       stdout=subprocess2.PIPE)
   self.assertEquals(subprocess2.TIMED_OUT, returncode)
   self.assertEquals(['', None], out)
开发者ID:lexuanquyen,项目名称:chromium_base,代码行数:8,代码来源:subprocess2_test.py

示例2: test_stdout_void

 def test_stdout_void(self):
   (out, err), code = subprocess2.communicate(
        self.exe + ['--stdout', '--stderr'],
        stdout=subprocess2.VOID,
        stderr=subprocess2.PIPE)
   self.assertEquals(None, out)
   self.assertEquals('a\nbb\nccc\n', err)
   self.assertEquals(0, code)
开发者ID:lexuanquyen,项目名称:chromium_base,代码行数:8,代码来源:subprocess2_test.py

示例3: test_communicate_defaults

 def test_communicate_defaults(self):
   results = self._fake_Popen()
   self.assertEquals(
       ((None, None), -8), subprocess2.communicate(['foo'], a=True))
   expected = {
       'args': ['foo'],
       'a': True,
   }
   self.assertEquals(expected, results)
开发者ID:lexuanquyen,项目名称:chromium_base,代码行数:9,代码来源:subprocess2_test.py

示例4: test_stderr_void

 def test_stderr_void(self):
   (out, err), code = subprocess2.communicate(
        self.exe + ['--stdout', '--stderr'],
        universal_newlines=True,
        stdout=subprocess2.PIPE,
        stderr=subprocess2.VOID)
   self.assertEquals('A\nBB\nCCC\n', out)
   self.assertEquals(None, err)
   self.assertEquals(0, code)
开发者ID:lexuanquyen,项目名称:chromium_base,代码行数:9,代码来源:subprocess2_test.py

示例5: fn

 def fn(c, e, un):
   res = subprocess2.communicate(
       e + ['--stdout', '--read'],
       stdin=VOID,
       stdout=PIPE,
       timeout=10,
       universal_newlines=un,
       shell=False)
   self._check_res(res, c('A\nBB\nCCC\n'), None, 0)
开发者ID:173210,项目名称:depot_tools,代码行数:9,代码来源:subprocess2_test.py

示例6: test_tee_large_stdin

 def test_tee_large_stdin(self):
   stdout = []
   # Write 128kb.
   stdin = '0123456789abcdef' * (8*1024)
   res = subprocess2.communicate(
       self.exe + ['--large', '--read'], stdin=stdin, stdout=stdout.append)
   self.assertEquals(128*1024, len(''.join(stdout)))
   # Windows return code is > 8 bits.
   returncode = len(stdin) if sys.platform == 'win32' else 0
   self._check_res(res, None, None, returncode)
开发者ID:173210,项目名称:depot_tools,代码行数:10,代码来源:subprocess2_test.py

示例7: CallCommand

def CallCommand(cmd_data):
  # multiprocessing needs a top level function with a single argument.
  cmd_data.kwargs['stdout'] = subprocess.PIPE
  cmd_data.kwargs['stderr'] = subprocess.STDOUT
  try:
    (out, _), code = subprocess.communicate(cmd_data.cmd, **cmd_data.kwargs)
    if code != 0:
      return cmd_data.message('%s failed\n%s' % (cmd_data.name, out))
  except OSError as e:
    return cmd_data.message(
        '%s exec failure\n   %s' % (cmd_data.name, e))
开发者ID:Nitrillo,项目名称:webrtc-android,代码行数:11,代码来源:presubmit_support.py

示例8: check_call

    def check_call(self, *args):
        ((out, err), code) = subprocess2.communicate(
            (sys.executable, self.path) + args,
            stdout=subprocess2.PIPE,
            stderr=subprocess2.PIPE,
            env=self.get_sub_env(),
            timeout=self.timeout,
        )

        # Parse output.
        status_code_match = re.search("status=([0-9]+)", err)
        if status_code_match:
            return (int(status_code_match.group(1)), out, err)
        if "You are attempting to access protected data with " "no configured credentials." in err:
            return (403, out, err)
        if "No such object" in err:
            return (404, out, err)
        return (code, out, err)
开发者ID:Happy-Ferret,项目名称:webkit.js,代码行数:18,代码来源:download_from_google_storage.py

示例9: check_call

  def check_call(self, *args):
    cmd = [sys.executable, self.path, '--force-version', self.version]
    cmd.extend(args)
    ((out, err), code) = subprocess2.communicate(
        cmd,
        stdout=subprocess2.PIPE,
        stderr=subprocess2.PIPE,
        env=self.get_sub_env(),
        timeout=self.timeout)

    # Parse output.
    status_code_match = re.search('status=([0-9]+)', err)
    if status_code_match:
      return (int(status_code_match.group(1)), out, err)
    if ('You are attempting to access protected data with '
          'no configured credentials.' in err):
      return (403, out, err)
    if 'matched no objects' in err:
      return (404, out, err)
    return (code, out, err)
开发者ID:173210,项目名称:depot_tools,代码行数:20,代码来源:download_from_google_storage.py

示例10: check_call

  def check_call(self, *args):
    env = os.environ.copy()
    if self.boto_path:
      env['AWS_CREDENTIAL_FILE'] = self.boto_path
    ((out, err), code) = subprocess2.communicate(
        (sys.executable, self.path) + args,
        stdout=subprocess2.PIPE,
        stderr=subprocess2.PIPE,
        env=env,
        timeout=self.timeout)

    # Parse output.
    status_code_match = re.search('status=([0-9]+)', err)
    if status_code_match:
      return (int(status_code_match.group(1)), out, err)
    if ('You are attempting to access protected data with '
          'no configured credentials.' in err):
      return (403, out, err)
    if 'No such object' in err:
      return (404, out, err)
    return (code, out, err)
开发者ID:jgrowl,项目名称:depot_tools,代码行数:21,代码来源:download_from_google_storage.py


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