當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。