Eli Bendersky | 26e41c4 | 2011-12-28 09:21:14 +0200 | [diff] [blame^] | 1 | import os, subprocess |
| 2 | |
| 3 | |
| 4 | def 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 | |
| 17 | def 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 | |