blob: e09521c40167e244fcd6b9aca877f4b8ffc21536 [file] [log] [blame]
Eli Bendersky26e41c42011-12-28 09:21:14 +02001import os, subprocess
2
3
4def run_exe(exe_path, args):
5 """ Runs the given executable as a subprocess, given the
6 list of arguments. Captures its return code (rc) and stdout and
7 returns a pair: rc, stdout_str
8 """
9 popen_cmd = [exe_path] + args
10 if os.path.splitext(exe_path)[1] == '.py':
11 popen_cmd.insert(0, 'python')
12 proc = subprocess.Popen(popen_cmd, stdout=subprocess.PIPE)
13 proc_stdout = proc.communicate()[0]
14 return proc.returncode, proc_stdout
15
16
17def is_in_rootdir():
18 """ Check whether the current dir is the root dir of pyelftools
19 """
20 dirstuff = os.listdir('.')
21 return 'test' in dirstuff and 'elftools' in dirstuff
22