blob: 56ddd8db3f66339c78cd4fcfe03065fcc01a1a3b [file] [log] [blame]
Zachary Turner9dbf62f2015-11-02 22:41:01 +00001import six
2
3if six.PY2:
4 import commands
5 get_command_output = commands.getoutput
6 get_command_status_output = commands.getstatusoutput
7
Zachary Turnerbac6e4f2015-11-03 21:37:27 +00008 cmp_ = cmp
Zachary Turner9dbf62f2015-11-02 22:41:01 +00009else:
10 def get_command_status_output(command):
11 try:
12 import subprocess
Zachary Turnerbbc5b462015-11-04 01:03:47 +000013 return (0, subprocess.check_output(command, shell=True, universal_newlines=True))
Zachary Turner9dbf62f2015-11-02 22:41:01 +000014 except subprocess.CalledProcessError as e:
15 return (e.returncode, e.output)
16
17 def get_command_output(command):
18 return get_command_status_output(command)[1]
Zachary Turnerbac6e4f2015-11-03 21:37:27 +000019
20 cmp_ = lambda x, y: (x > y) - (x < y)