Python future.moves.subprocess.CalledProcessError.output() Examples
The following are 30
code examples of future.moves.subprocess.CalledProcessError.output().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
future.moves.subprocess.CalledProcessError
, or try the search function
.
Example #1
Source File: base.py From Tautulli with GNU General Public License v3.0 | 6 votes |
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())
Example #2
Source File: base.py From arissploit with GNU General Public License v3.0 | 6 votes |
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())
Example #3
Source File: base.py From blackmamba with MIT License | 6 votes |
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())
Example #4
Source File: base.py From gimp-plugin-export-layers with GNU General Public License v3.0 | 6 votes |
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())
Example #5
Source File: base.py From deepWordBug with Apache License 2.0 | 6 votes |
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())
Example #6
Source File: base.py From deepWordBug with Apache License 2.0 | 6 votes |
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)
Example #7
Source File: base.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
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)
Example #8
Source File: base.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
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())
Example #9
Source File: base.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
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)
Example #10
Source File: base.py From telegram-robot-rss with Mozilla Public License 2.0 | 6 votes |
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())
Example #11
Source File: base.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
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())
Example #12
Source File: base.py From addon with GNU General Public License v3.0 | 6 votes |
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())
Example #13
Source File: base.py From verge3d-blender-addon with GNU General Public License v3.0 | 6 votes |
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)
Example #14
Source File: base.py From verge3d-blender-addon with GNU General Public License v3.0 | 6 votes |
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())
Example #15
Source File: base.py From gimp-plugin-export-layers with GNU General Public License v3.0 | 5 votes |
def __init__(self, msg, returncode, cmd, output=None): self.msg = msg self.returncode = returncode self.cmd = cmd self.output = output
Example #16
Source File: base.py From gimp-plugin-export-layers with GNU General Public License v3.0 | 5 votes |
def __str__(self): return ("Command '%s' failed with exit status %d\nMessage: %s\nOutput: %s" % (self.cmd, self.returncode, self.msg, self.output))
Example #17
Source File: base.py From Tautulli with GNU General Public License v3.0 | 5 votes |
def __str__(self): return ("Command '%s' failed with exit status %d\nMessage: %s\nOutput: %s" % (self.cmd, self.returncode, self.msg, self.output))
Example #18
Source File: base.py From Tautulli with GNU General Public License v3.0 | 5 votes |
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
Example #19
Source File: base.py From Tautulli with GNU General Public License v3.0 | 5 votes |
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)
Example #20
Source File: base.py From Tautulli with GNU General Public License v3.0 | 5 votes |
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 ...
Example #21
Source File: base.py From gimp-plugin-export-layers with GNU General Public License v3.0 | 5 votes |
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 ...
Example #22
Source File: base.py From blackmamba with MIT License | 5 votes |
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 ...
Example #23
Source File: base.py From blackmamba with MIT License | 5 votes |
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)
Example #24
Source File: base.py From blackmamba with MIT License | 5 votes |
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
Example #25
Source File: base.py From blackmamba with MIT License | 5 votes |
def __str__(self): return ("Command '%s' failed with exit status %d\nMessage: %s\nOutput: %s" % (self.cmd, self.returncode, self.msg, self.output))
Example #26
Source File: base.py From blackmamba with MIT License | 5 votes |
def __init__(self, msg, returncode, cmd, output=None): self.msg = msg self.returncode = returncode self.cmd = cmd self.output = output
Example #27
Source File: base.py From addon with GNU General Public License v3.0 | 5 votes |
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 ...
Example #28
Source File: base.py From addon with GNU General Public License v3.0 | 5 votes |
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)
Example #29
Source File: base.py From addon with GNU General Public License v3.0 | 5 votes |
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
Example #30
Source File: base.py From addon with GNU General Public License v3.0 | 5 votes |
def __str__(self): return ("Command '%s' failed with exit status %d\nMessage: %s\nOutput: %s" % (self.cmd, self.returncode, self.msg, self.output))