chiark / gitweb /
common.prepare_source: better detection of errors
authorTias Guns <tias@ulyssis.org>
Mon, 12 Mar 2012 21:08:43 +0000 (21:08 +0000)
committerTias Guns <tias@ulyssis.org>
Mon, 12 Mar 2012 23:07:41 +0000 (23:07 +0000)
when running 'android update', sometimes the program returns an error on
stderr without giving a !=0 errorcode.
This patch detects such an error, and throws a proper BuildException

(in my case, it printed the following to stderr:
Error: The project either has no target set or the target is invalid.
Please provide a --target to the 'android update' command.)

fdroidserver/common.py

index e170169b2454aad7840fa3f846a05ceb93637327..18607665281e4cfee2edbbdf86cdffed80fefbdf 100644 (file)
@@ -737,8 +737,13 @@ def prepare_source(vcs, app, build, build_dir, extlib_dir, sdk_path, ndk_path, j
             if verbose:
                 print "Update of '%s': exec '%s' in '%s'"%\
                     (d," ".join(parms),cwd)
-            if subprocess.call(parms, cwd=cwd) != 0:
-                raise BuildException("Failed to update project")
+            p = subprocess.Popen(parms, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+            (out, err) = p.communicate()
+            if p.returncode != 0:
+                raise BuildException("Failed to update project with stdout '%s' and stderr '%s'"%(out,err))
+            # check to see whether an error was returned without a proper exit code (this is the case for the 'no target set or target invalid' error)
+            if err != "" and err.startswith("Error: "):
+                raise BuildException("Failed to update project with stdout '%s' and stderr '%s'"%(out,err))
 
     # If the app has ant set up to sign the release, we need to switch
     # that off, because we want the unsigned apk...