X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=fdroidserver%2Fcommon.py;h=0b4c2dd007c3f201cedcb2bdbf309a9a4db9ea79;hb=bf3247743344edf676a51c568cc35f6f0bdc95e5;hp=36c588d0862781dfc403236f9180d135617a6f8d;hpb=9f95c0bbdb48a552606a5f6e3826d0d044a7ab02;p=fdroidserver.git diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 36c588d0..0b4c2dd0 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1626,7 +1626,7 @@ def SdkToolsPopen(commands, cwd=None, output=True): cwd=cwd, output=output) -def FDroidPopen(commands, cwd=None, output=True): +def FDroidPopen(commands, cwd=None, output=True, stderr_to_stdout=True): """ Run a command and capture the possibly huge output. @@ -1642,15 +1642,28 @@ def FDroidPopen(commands, cwd=None, output=True): logging.debug("Directory: %s" % cwd) logging.debug("> %s" % ' '.join(commands)) + stderr_param = subprocess.STDOUT if stderr_to_stdout else subprocess.PIPE result = PopenResult() p = None try: p = subprocess.Popen(commands, cwd=cwd, shell=False, env=env, - stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + stdout=subprocess.PIPE, stderr=stderr_param) except OSError as e: raise BuildException("OSError while trying to execute " + ' '.join(commands) + ': ' + str(e)) + if not stderr_to_stdout and options.verbose: + stderr_queue = Queue() + stderr_reader = AsynchronousFileReader(p.stderr, stderr_queue) + + while not stderr_reader.eof(): + while not stderr_queue.empty(): + line = stderr_queue.get() + sys.stderr.write(line) + sys.stderr.flush() + + time.sleep(0.1) + stdout_queue = Queue() stdout_reader = AsynchronousFileReader(p.stdout, stdout_queue)