1 | from __future__ import absolute_import |
||
2 | from __future__ import print_function |
||
3 | |||
4 | import subprocess |
||
5 | |||
6 | try: |
||
7 | import queue as Queue |
||
8 | except ImportError: |
||
9 | import Queue |
||
10 | |||
11 | |||
12 | def subprocess_check_output(*popenargs, **kwargs): |
||
13 | # Backport of subprocess.check_output taken from |
||
14 | # https://gist.github.com/edufelipe/1027906 |
||
15 | # |
||
16 | # Originally from Python 2.7 stdlib under PSF, compatible with BSD-3 |
||
17 | # Copyright (c) 2003-2005 by Peter Astrand <[email protected]> |
||
18 | # Changes by Eduardo Felipe |
||
19 | |||
20 | process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs) |
||
21 | output, unused_err = process.communicate() |
||
22 | retcode = process.poll() |
||
23 | if retcode: |
||
24 | cmd = kwargs.get("args") |
||
25 | if cmd is None: |
||
26 | cmd = popenargs[0] |
||
27 | error = subprocess.CalledProcessError(retcode, cmd) |
||
28 | error.output = output |
||
29 | raise error |
||
30 | return output |
||
31 | |||
32 | |||
33 | if hasattr(subprocess, "check_output"): |
||
34 | # if available we just use the real function |
||
35 | subprocess_check_output = subprocess.check_output |
||
36 | |||
37 | |||
38 | def input_func(prompt=None): |
||
39 | try: |
||
40 | return str(raw_input(prompt)) |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
![]() |
|||
41 | except NameError: |
||
42 | return input(prompt) |
||
43 | |||
44 | |||
45 | unicode_func = str |
||
46 | try: |
||
47 | unicode_func = unicode |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
48 | except NameError: |
||
49 | pass |
||
50 |