selftests/cyclical_deps: Make it compatible with python 2.6

subprocess.check_output is a new API starting in python 2.7.
So let's use our in house subprocess lib here to make it
compatible with 2.6.
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 c8721e0d
......@@ -3,7 +3,8 @@
from __future__ import print_function
"""Simple script to test cyclical dependencies in modules.
"""
Simple script to test cyclical dependencies in modules.
Requirements:
- SnakeFood (pip install snakefood)
......@@ -24,6 +25,15 @@ except ImportError:
print("Please, install 'python-networkx' with yum or apt.", file=sys.stderr)
sys.exit(2)
# simple magic for using scripts within a source tree
basedir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if os.path.isdir(os.path.join(basedir, 'avocado')):
os.environ['PATH'] += ":" + os.path.join(basedir, 'scripts')
os.environ['PATH'] += ":" + os.path.join(basedir, 'libexec')
sys.path.append(basedir)
from avocado.utils import process
def has_snakefood():
with open(os.devnull, 'w') as null:
......@@ -39,9 +49,10 @@ def has_snakefood():
def generate_dot_file(path):
cmdline = 'sfood --internal %s | sfood-graph --remove-extensions'
output = subprocess.check_output(cmdline % path, shell=True)
output = process.system_output(cmdline % path, shell=True)
tmp = tempfile.mktemp()
fd = open(tmp, 'w').write(output)
with open(tmp, 'w') as sfood_file:
sfood_file.write(output)
return tmp
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册