You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ti...@apache.org on 2019/01/09 15:49:56 UTC

[mesos] branch master updated: Improved debuggability of `verify-reviews.py`.

This is an automated email from the ASF dual-hosted git repository.

tillt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git


The following commit(s) were added to refs/heads/master by this push:
     new f6b3dc1  Improved debuggability of  `verify-reviews.py`.
f6b3dc1 is described below

commit f6b3dc126047b1f1a8568b3b3424c86960934a58
Author: Armand Grillet <ag...@mesosphere.io>
AuthorDate: Wed Jan 9 16:49:43 2019 +0100

    Improved debuggability of  `verify-reviews.py`.
    
    Improves error handling in `shell()` and decodes what is returned
    by `urllib.request.urlopen` when doing API calls.
    
    Review: https://reviews.apache.org/r/69701/
---
 support/verify-reviews.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/support/verify-reviews.py b/support/verify-reviews.py
index 04ed7fe..71326d3 100755
--- a/support/verify-reviews.py
+++ b/support/verify-reviews.py
@@ -93,8 +93,12 @@ class ReviewError(Exception):
 
 def shell(command):
     """Run a shell command."""
-    print(command)
-    out = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
+    try:
+        out = subprocess.check_output(
+            command, stderr=subprocess.STDOUT, shell=True)
+    except subprocess.CalledProcessError as err:
+        print("Error running command '%s': %s" % (command, err.output))
+        exit(1)
     return out.decode(sys.stdout.encoding)
 
 
@@ -113,7 +117,8 @@ def api(url, data=None):
 
         if isinstance(data, str):
             data = str.encode(data)
-        return json.loads(urllib.request.urlopen(url, data=data).read())
+        f = urllib.request.urlopen(url, data=data)
+        return json.loads(f.read().decode("utf-8"))
     except urllib.error.HTTPError as err:
         print("Error handling URL %s: %s (%s)" % (url, err.reason, err.read()))
         exit(1)