Index: third_party/libadblockplus_android/subproc.py |
diff --git a/third_party/libadblockplus_android/subproc.py b/third_party/libadblockplus_android/subproc.py |
index 100059a1e9a17a45ea0d596da057fa5350849864..3df27e032f9b2d1ea11792bc51c0b5f7fd5318a1 100644 |
--- a/third_party/libadblockplus_android/subproc.py |
+++ b/third_party/libadblockplus_android/subproc.py |
@@ -1,36 +1,38 @@ |
import os |
-import io |
import sys |
import subprocess |
+ |
def main(argv): |
- cwd = os.getcwd() |
- subprocess_env = os.environ.copy() |
- subprocess_args = [] |
- for arg in argv: |
- # if it's env var |
- if arg[: 5] == '--env': |
- equal_pos = arg.index('=') |
- key = arg[5 : equal_pos] |
- value = arg[equal_pos + 1 : len(arg)] |
- print('Set env variable %s=%s' % (key, value)) |
- subprocess_env[key] = value |
- else: |
- # if it's cwd |
- if arg[: 5] == '--cwd': |
- cwd = arg[5:] |
- print('Set cwd=%s' % cwd) |
- else: |
- # cmd arguments |
- subprocess_args += [ arg ] |
+ cwd = os.getcwd() |
+ subprocess_env = os.environ.copy() |
+ subprocess_args = [] |
+ for arg in argv: |
+ # if it's env var |
+ if arg[: 5] == '--env': |
+ equal_pos = arg.index('=') |
+ key = arg[5:equal_pos] |
+ value = arg[equal_pos + 1:len(arg)] |
+ print('Set env variable {}={}'.format(key, value)) |
+ subprocess_env[key] = value |
+ else: |
+ # if it's cwd |
+ if arg[: 5] == '--cwd': |
+ cwd = arg[5:] |
+ print('Set cwd={}'.format(cwd)) |
+ else: |
+ # cmd arguments |
+ subprocess_args += [arg] |
+ |
+ process = subprocess.Popen(subprocess_args, env=subprocess_env, |
+ cwd=cwd, stdout=sys.stdout, stderr=sys.stderr) |
+ process.communicate() |
+ return process.returncode |
- #print("Running: %s" % " ".join(subprocess_args)) |
- process = subprocess.Popen(subprocess_args, env=subprocess_env, cwd=cwd, stdout=sys.stdout, stderr=sys.stderr) |
- return process.returncode |
if '__main__' == __name__: |
- try: |
- sys.exit(main(sys.argv[1:])) |
- except KeyboardInterrupt: |
- sys.stderr.write('interrupted\n') |
- sys.exit(1) |
+ try: |
+ sys.exit(main(sys.argv[1:])) |
+ except KeyboardInterrupt: |
+ sys.stderr.write('interrupted\n') |
+ sys.exit(1) |