Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: third_party/libadblockplus_android/subproc.py

Issue 29670584: Issue 6277 - Subproc.py should wait for subprocess to finish (Closed)
Patch Set: Created Jan. 16, 2018, 12:01 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libadblockplus/subproc.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « third_party/libadblockplus/subproc.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld