From 890a1adb6f9ed6fbac9af29638b032527686a4c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Wed, 2 Oct 2013 19:28:43 +0200 Subject: [PATCH] Do not repeat stderr and stdout when -v/--verbose --- fdroidserver/build.py | 36 +++++++++++++++++++++++------------- fdroidserver/common.py | 8 ++++---- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/fdroidserver/build.py b/fdroidserver/build.py index 6b400e97..b9e75045 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -305,7 +305,7 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, sdk_path, force): while chan.recv_stderr_ready(): error += chan.recv_stderr(1024) if returncode != 0: - raise BuildException("Build.py failed on server for %s:%s" % (app['id'], thisbuild['version']), output.strip(), error.strip()) + raise BuildException("Build.py failed on server for %s:%s" % (app['id'], thisbuild['version']), output, error) # Retrieve the built files... print "Retrieving build output..." @@ -319,7 +319,7 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, sdk_path, force): ftp.get(apkfile, os.path.join(output_dir, apkfile)) ftp.get(tarball, os.path.join(output_dir, tarball)) except: - raise BuildException("Build failed for %s:%s" % (app['id'], thisbuild['version']), output.strip(), error.strip()) + raise BuildException("Build failed for %s:%s" % (app['id'], thisbuild['version']), output, error) ftp.close() finally: @@ -428,8 +428,12 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d raise BuildException("NDK build failed for %s:%s" % (app['id'], thisbuild['version'])) p = None - output = "" - error = "" + if verbose: + output = None + error = None + else: + output = '' + error = '' # Build the release... if 'maven' in thisbuild: print "Building Maven project..." @@ -453,13 +457,15 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d # Output directly to console sys.stdout.write(line) sys.stdout.flush() - output += line + else: + output += line for line in iter(p.stderr.readline, ''): if verbose: # Output directly to console sys.stdout.write(line) sys.stdout.flush() - error += line + else: + error += line elif 'gradle' in thisbuild: print "Building Gradle project..." @@ -509,13 +515,15 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d # Output directly to console sys.stdout.write(line) sys.stdout.flush() - output += line + else: + output += line for line in iter(p.stderr.readline, ''): if verbose: # Output directly to console sys.stdout.write(line) sys.stdout.flush() - error += line + else: + error += line else: print "Building Ant project..." @@ -532,23 +540,25 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d # Output directly to console sys.stdout.write(line) sys.stdout.flush() - output += line + else: + output += line for line in iter(p.stderr.readline, ''): if verbose: # Output directly to console sys.stdout.write(line) sys.stdout.flush() - error += line + else: + error += line p.communicate() if p.returncode != 0: - raise BuildException("Build failed for %s:%s" % (app['id'], thisbuild['version']), output.strip(), error.strip()) + raise BuildException("Build failed for %s:%s" % (app['id'], thisbuild['version']), output, error) if install: if 'maven' in thisbuild: p = subprocess.Popen([mvn3, 'android:deploy', '-Dandroid.sdk.path=' + sdk_path], cwd=root_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output_, error = p.communicate() + output_, error_ = p.communicate() if p.returncode != 0: - raise BuildException("Warning: Could not deploy %s:%s" % (app['id'], thisbuild['version']), output_.strip(), error.strip()) + raise BuildException("Warning: Could not deploy %s:%s" % (app['id'], thisbuild['version']), output_, error_) return print "Successfully built version " + thisbuild['version'] + ' of ' + app['id'] diff --git a/fdroidserver/common.py b/fdroidserver/common.py index dda00f02..c4b9beea 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1015,9 +1015,9 @@ class BuildException(Exception): def __str__(self): ret = repr(self.value) if self.stdout: - ret = ret + "\n==== stdout begin ====\n" + str(self.stdout) + "\n==== stdout end ====" + ret += "\n==== stdout begin ====\n%s\n==== stdout end ====" % self.stdout.strip() if self.stderr: - ret = ret + "\n==== stderr begin ====\n" + str(self.stderr) + "\n==== stderr end ====" + ret += "\n==== stderr begin ====\n%s\n==== stderr end ====" % self.stderr.strip() return ret class VCSException(Exception): @@ -1657,8 +1657,8 @@ def isApkDebuggable(apkfile): execfile('config.py', globals()) p = subprocess.Popen([os.path.join(sdk_path, 'build-tools', build_tools, 'aapt'), - 'dump', 'xmltree', apkfile, 'AndroidManifest.xml'], - stdout=subprocess.PIPE) + 'dump', 'xmltree', apkfile, 'AndroidManifest.xml'], + stdout=subprocess.PIPE) output = p.communicate()[0] if p.returncode != 0: print "ERROR: Failed to get apk manifest information"