MCPcopy Create free account
hub / github.com/apache/cloudstack / check_output

Function check_output

test/systemvm/__init__.py:25–43  ·  view source on GitHub ↗

r"""Run command with arguments and return its output as a byte string. Backported from Python 2.7 as it's implemented as pure python on stdlib. >>> check_output(['/usr/bin/python', '--version']) Python 2.6.2

(*popenargs, **kwargs)

Source from the content-addressed store, hash-verified

23except (NameError, ImportError):
24 import subprocess
25 def check_output(*popenargs, **kwargs):
26 r"""Run command with arguments and return its output as a byte string.
27
28 Backported from Python 2.7 as it's implemented as pure python on stdlib.
29
30 >>> check_output(['/usr/bin/python', '--version'])
31 Python 2.6.2
32 """
33 process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
34 output, unused_err = process.communicate()
35 retcode = process.poll()
36 if retcode:
37 cmd = kwargs.get("args")
38 if cmd is None:
39 cmd = popenargs[0]
40 error = subprocess.CalledProcessError(retcode, cmd)
41 error.output = output
42 raise error
43 return output
44 subprocess.check_output = check_output
45
46import logging

Callers 1

executeFunction · 0.85

Calls 2

pollMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected