2015-11-03 06:41:01 +08:00
|
|
|
import six
|
|
|
|
|
|
|
|
if six.PY2:
|
|
|
|
import commands
|
|
|
|
get_command_output = commands.getoutput
|
|
|
|
get_command_status_output = commands.getstatusoutput
|
|
|
|
|
2015-11-04 05:37:27 +08:00
|
|
|
cmp_ = cmp
|
2015-11-03 06:41:01 +08:00
|
|
|
else:
|
|
|
|
def get_command_status_output(command):
|
|
|
|
try:
|
|
|
|
import subprocess
|
2016-09-07 04:57:50 +08:00
|
|
|
return (
|
|
|
|
0,
|
|
|
|
subprocess.check_output(
|
|
|
|
command,
|
|
|
|
shell=True,
|
|
|
|
universal_newlines=True))
|
2015-11-03 06:41:01 +08:00
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
return (e.returncode, e.output)
|
|
|
|
|
|
|
|
def get_command_output(command):
|
|
|
|
return get_command_status_output(command)[1]
|
2015-11-04 05:37:27 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
cmp_ = lambda x, y: (x > y) - (x < y)
|