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


Python CalledProcessError.output方法代码示例

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


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

示例1: compare

# 需要导入模块: from future.moves.subprocess import CalledProcessError [as 别名]
# 或者: from future.moves.subprocess.CalledProcessError import output [as 别名]
def compare(self, output, expected, ignore_imports=True):
        """
        Compares whether the code blocks are equal. If not, raises an
        exception so the test fails. Ignores any trailing whitespace like
        blank lines.

        If ignore_imports is True, passes the code blocks into the
        strip_future_imports method.

        If one code block is a unicode string and the other a
        byte-string, it assumes the byte-string is encoded as utf-8.
        """
        if ignore_imports:
            output = self.strip_future_imports(output)
            expected = self.strip_future_imports(expected)
        if isinstance(output, bytes) and not isinstance(expected, bytes):
            output = output.decode('utf-8')
        if isinstance(expected, bytes) and not isinstance(output, bytes):
            expected = expected.decode('utf-8')
        self.assertEqual(order_future_lines(output.rstrip()),
                         expected.rstrip()) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:23,代码来源:base.py

示例2: __init__

# 需要导入模块: from future.moves.subprocess import CalledProcessError [as 别名]
# 或者: from future.moves.subprocess.CalledProcessError import output [as 别名]
def __init__(self, msg, returncode, cmd, output=None):
        self.msg = msg
        self.returncode = returncode
        self.cmd = cmd
        self.output = output 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:7,代码来源:base.py

示例3: __str__

# 需要导入模块: from future.moves.subprocess import CalledProcessError [as 别名]
# 或者: from future.moves.subprocess.CalledProcessError import output [as 别名]
def __str__(self):
        return ("Command '%s' failed with exit status %d\nMessage: %s\nOutput: %s"
                % (self.cmd, self.returncode, self.msg, self.output)) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:5,代码来源:base.py

示例4: convert

# 需要导入模块: from future.moves.subprocess import CalledProcessError [as 别名]
# 或者: from future.moves.subprocess.CalledProcessError import output [as 别名]
def convert(self, code, stages=(1, 2), all_imports=False, from3=False,
                reformat=True, run=True, conservative=False):
        """
        Converts the code block using ``futurize`` and returns the
        resulting code.
        
        Passing stages=[1] or stages=[2] passes the flag ``--stage1`` or
        ``stage2`` to ``futurize``. Passing both stages runs ``futurize``
        with both stages by default.

        If from3 is False, runs ``futurize``, converting from Python 2 to
        both 2 and 3. If from3 is True, runs ``pasteurize`` to convert
        from Python 3 to both 2 and 3.

        Optionally reformats the code block first using the reformat() function.

        If run is True, runs the resulting code under all Python
        interpreters in self.interpreters.
        """
        if reformat:
            code = reformat_code(code)
        self._write_test_script(code)
        self._futurize_test_script(stages=stages, all_imports=all_imports,
                                   from3=from3, conservative=conservative)
        output = self._read_test_script()
        if run:
            for interpreter in self.interpreters:
                _ = self._run_test_script(interpreter=interpreter)
        return output 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:31,代码来源:base.py

示例5: strip_future_imports

# 需要导入模块: from future.moves.subprocess import CalledProcessError [as 别名]
# 或者: from future.moves.subprocess.CalledProcessError import output [as 别名]
def strip_future_imports(self, code):
        """
        Strips any of these import lines:

            from __future__ import <anything>
            from future <anything>
            from future.<anything>
            from builtins <anything>

        or any line containing:
            install_hooks()
        or:
            install_aliases()

        Limitation: doesn't handle imports split across multiple lines like
        this:

            from __future__ import (absolute_import, division, print_function,
                                    unicode_literals)
        """
        output = []
        # We need .splitlines(keepends=True), which doesn't exist on Py2,
        # so we use this instead:
        for line in code.split('\n'):
            if not (line.startswith('from __future__ import ')
                    or line.startswith('from future ')
                    or line.startswith('from builtins ')
                    or 'install_hooks()' in line
                    or 'install_aliases()' in line
                    # but don't match "from future_builtins" :)
                    or line.startswith('from future.')):
                output.append(line)
        return '\n'.join(output) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:35,代码来源:base.py

示例6: _run_test_script

# 需要导入模块: from future.moves.subprocess import CalledProcessError [as 别名]
# 或者: from future.moves.subprocess.CalledProcessError import output [as 别名]
def _run_test_script(self, filename='mytestscript.py',
                         interpreter=sys.executable):
        # Absolute file path:
        fn = self.tempdir + filename
        try:
            output = check_output([interpreter, fn],
                                  env=self.env, stderr=STDOUT)
        except CalledProcessError as e:
            with open(fn) as f:
                msg = (
                    'Error running the command %s\n'
                    '%s\n'
                    'Contents of file %s:\n'
                    '\n'
                    '%s') % (
                        ' '.join([interpreter, fn]),
                        'env=%s' % self.env,
                        fn,
                        '----\n%s\n----' % f.read(),
                    )
            if not hasattr(e, 'output'):
                # The attribute CalledProcessError.output doesn't exist on Py2.6
                e.output = None
            raise VerboseCalledProcessError(msg, e.returncode, e.cmd, output=e.output)
        return output


# Decorator to skip some tests on Python 2.6 ... 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:30,代码来源:base.py

示例7: convert

# 需要导入模块: from future.moves.subprocess import CalledProcessError [as 别名]
# 或者: from future.moves.subprocess.CalledProcessError import output [as 别名]
def convert(self, code, stages=(1, 2), all_imports=False, from3=False,
                reformat=True, run=True, conservative=False):
        """
        Converts the code block using ``futurize`` and returns the
        resulting code.

        Passing stages=[1] or stages=[2] passes the flag ``--stage1`` or
        ``stage2`` to ``futurize``. Passing both stages runs ``futurize``
        with both stages by default.

        If from3 is False, runs ``futurize``, converting from Python 2 to
        both 2 and 3. If from3 is True, runs ``pasteurize`` to convert
        from Python 3 to both 2 and 3.

        Optionally reformats the code block first using the reformat() function.

        If run is True, runs the resulting code under all Python
        interpreters in self.interpreters.
        """
        if reformat:
            code = reformat_code(code)
        self._write_test_script(code)
        self._futurize_test_script(stages=stages, all_imports=all_imports,
                                   from3=from3, conservative=conservative)
        output = self._read_test_script()
        if run:
            for interpreter in self.interpreters:
                _ = self._run_test_script(interpreter=interpreter)
        return output 
开发者ID:remg427,项目名称:misp42splunk,代码行数:31,代码来源:base.py

示例8: convert_check

# 需要导入模块: from future.moves.subprocess import CalledProcessError [as 别名]
# 或者: from future.moves.subprocess.CalledProcessError import output [as 别名]
def convert_check(self, before, expected, stages=(1, 2), all_imports=False,
                      ignore_imports=True, from3=False, run=True,
                      conservative=False):
        """
        Convenience method that calls convert() and compare().

        Reformats the code blocks automatically using the reformat_code()
        function.

        If all_imports is passed, we add the appropriate import headers
        for the stage(s) selected to the ``expected`` code-block, so they
        needn't appear repeatedly in the test code.

        If ignore_imports is True, ignores the presence of any lines
        beginning:

            from __future__ import ...
            from future import ...

        for the purpose of the comparison.
        """
        output = self.convert(before, stages=stages, all_imports=all_imports,
                              from3=from3, run=run, conservative=conservative)
        if all_imports:
            headers = self.headers2 if 2 in stages else self.headers1
        else:
            headers = ''

        self.compare(output, headers + reformat_code(expected),
                     ignore_imports=ignore_imports) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:32,代码来源:base.py


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