• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python subprocess2.communicate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python subprocess32.call函数代码示例发布时间:2022-05-27
下一篇:
Python subprocess2.check_output函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap