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


Python CalledProcessError.stderr方法代码示例

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


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

示例1: test_fails_on_non_expected_exception

# 需要导入模块: from subprocess import CalledProcessError [as 别名]
# 或者: from subprocess.CalledProcessError import stderr [as 别名]
    def test_fails_on_non_expected_exception(self):
        mock_client = _get_time_noop_mock_client()

        exp = CalledProcessError(-1, 'blah')
        exp.stderr = '"" is not a valid tag'
        controller_client = Mock()
        controller_client.get_models.side_effect = [exp]
        mock_client.get_controller_client.return_value = controller_client
        with self.assertRaises(CalledProcessError):
            amm.wait_until_model_disappears(
                mock_client, 'test_model', timeout=60)
开发者ID:mjs,项目名称:juju,代码行数:13,代码来源:test_assess_model_migration.py

示例2: check_output

# 需要导入模块: from subprocess import CalledProcessError [as 别名]
# 或者: from subprocess.CalledProcessError import stderr [as 别名]
def check_output(run_args, *args, **kwargs):
    kwargs['stdout'] = PIPE
    kwargs['stderr'] = PIPE

    process = Popen(run_args, *args, **kwargs)
    stdout, stderr = process.communicate()

    retcode = process.poll()
    if retcode is not 0:
        exception = CalledProcessError(retcode, run_args[0])
        exception.stdout = stdout
        exception.stderr = stderr
        raise exception

    return stdout, stderr
开发者ID:awesome-security,项目名称:High-Speed-Packet-Capture,代码行数:17,代码来源:utils.py

示例3: check_call_capturing

# 需要导入模块: from subprocess import CalledProcessError [as 别名]
# 或者: from subprocess.CalledProcessError import stderr [as 别名]
def check_call_capturing(arguments, input = None, preexec_fn = None):
    """Spawn a process and return its output."""

    (stdout, stderr, code) = call_capturing(arguments, input, preexec_fn)

    if code == 0:
        return (stdout, stderr)
    else:
        from subprocess import CalledProcessError

        error = CalledProcessError(code, arguments)

        error.stdout = stdout
        error.stderr = stderr

        raise error
开发者ID:borg-project,项目名称:utcondor,代码行数:18,代码来源:raw.py

示例4: test_ignores_model_detail_exceptions

# 需要导入模块: from subprocess import CalledProcessError [as 别名]
# 或者: from subprocess.CalledProcessError import stderr [as 别名]
    def test_ignores_model_detail_exceptions(self):
        """ignore errors for model details as this might happen many times."""
        mock_client = _get_time_noop_mock_client()
        model_data = {'models': [{'name': ''}]}

        exp = CalledProcessError(-1, 'blah')
        exp.stderr = 'cannot get model details'
        controller_client = Mock()
        controller_client.get_models.side_effect = [
            exp,
            model_data]
        mock_client.get_controller_client.return_value = controller_client
        with patch.object(amm, 'sleep') as mock_sleep:
            amm.wait_until_model_disappears(
                mock_client, 'test_model', timeout=60)
            mock_sleep.assert_called_once_with(1)
开发者ID:mjs,项目名称:juju,代码行数:18,代码来源:test_assess_model_migration.py

示例5: func

# 需要导入模块: from subprocess import CalledProcessError [as 别名]
# 或者: from subprocess.CalledProcessError import stderr [as 别名]
 def func(*args):
     """Wrapper function used to append arguments to command."""
     cmd = [command_line]
     cmd += [str(arg) for arg in args]
     proc = subprocess.Popen(cmd, stderr=PIPE, stdout=PIPE)
     stdout, stderr = proc.communicate()
     proc.wait()
     if proc.returncode:
         err = CalledProcessError(
             returncode=proc.returncode,
             cmd=" ".join(cmd),
             output=stdout,
         )
         err.stderr = stderr
         raise err
     return stdout, stderr
开发者ID:concretecloud,项目名称:c4irp,代码行数:18,代码来源:sh.py

示例6: __submit

# 需要导入模块: from subprocess import CalledProcessError [as 别名]
# 或者: from subprocess.CalledProcessError import stderr [as 别名]
    def __submit(self, call, env):
        output_chunks = []
        process = Popen(call, env=env, stderr=STDOUT, stdout=PIPE)
        while process.returncode is None:
            output_chunks.append(process.communicate())
            sleep(0.1)
        stdout = "".join([c[0].decode('utf-8') for c in output_chunks if c[0] is not None])
        stderr = "".join([c[1].decode('utf-8') for c in output_chunks if c[1] is not None])

        if process.returncode == 0:
            return stdout, stderr

        exc = CalledProcessError(process.returncode, call)
        exc.stdout = stdout
        exc.stderr = stderr

        print(stdout)
        print(stderr)

        raise exc
开发者ID:jbzdak,项目名称:torque-submitter,代码行数:22,代码来源:_submit.py

示例7: check_output

# 需要导入模块: from subprocess import CalledProcessError [as 别名]
# 或者: from subprocess.CalledProcessError import stderr [as 别名]
def check_output(command, cwd=None, shell=False, env=None,
                 stdin=__sentinel__, stderr=__sentinel__,
                 preexec_fn=None, use_texpath=True,
                 show_window=False):
    '''
    Takes a command to be passed to subprocess.Popen.

    Returns the output if the command was successful.

    By default stderr is redirected to stdout, so this will return any output
    to either stream. This can be changed by calling execute_command with
    stderr set to subprocess.PIPE or any other valid value.

    Raises CalledProcessError if the command returned a non-zero value
    Raises OSError if the executable is not found

    This is pretty much identical to subprocess.check_output(), but
    implemented here since it is unavailable in Python 2.6's library.
    '''
    returncode, stdout, stderr = execute_command(
        command,
        cwd=cwd,
        shell=shell,
        env=env,
        stdin=stdin,
        stderr=stderr,
        preexec_fn=preexec_fn,
        use_texpath=use_texpath,
        show_window=show_window
    )

    if returncode:
        e = CalledProcessError(
            returncode,
            command
        )
        e.output = stdout
        e.stderr = stderr
        raise e

    return stdout
开发者ID:wampixel,项目名称:config,代码行数:43,代码来源:external_command.py


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