yetus-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject yetus git commit: YETUS-446 releasedocmaker not handling 0 version in a range correctly
Date Thu, 15 Sep 2016 20:39:28 GMT
Repository: yetus
Updated Branches:
  refs/heads/master d9abd010b -> c3a2359f6


YETUS-446 releasedocmaker not handling 0 version in a range correctly

Signed-off-by: Allen Wittenauer <aw@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/yetus/repo
Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/c3a2359f
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/c3a2359f
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/c3a2359f

Branch: refs/heads/master
Commit: c3a2359f6b463676e62121d72ede0f0a8487841d
Parents: d9abd01
Author: Ajay Yadava <ajayyadava@apache.org>
Authored: Sat Sep 10 12:04:10 2016 +0530
Committer: Allen Wittenauer <aw@apache.org>
Committed: Thu Sep 15 13:39:30 2016 -0700

----------------------------------------------------------------------
 release-doc-maker/releasedocmaker.py | 37 +++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/yetus/blob/c3a2359f/release-doc-maker/releasedocmaker.py
----------------------------------------------------------------------
diff --git a/release-doc-maker/releasedocmaker.py b/release-doc-maker/releasedocmaker.py
index 13eeb7f..9987355 100755
--- a/release-doc-maker/releasedocmaker.py
+++ b/release-doc-maker/releasedocmaker.py
@@ -116,17 +116,30 @@ class GetVersions(object):
         for project in projects:
             url = JIRA_BASE_URL + \
               "/rest/api/2/project/%s/versions" % project.upper()
-            resp = urllib2.urlopen(url)
+            try:
+                resp = urllib2.urlopen(url)
+            except urllib2.HTTPError as err:
+                code = err.code
+                print "JIRA returns HTTP error %d: %s. Aborting." % (code, err.msg)
+                error_response = err.read()
+                try:
+                    error_response = json.loads(error_response)
+                    print "- Please ensure that specified projects are correct."
+                    for message in error_response['errorMessages']:
+                        print "-", message
+                except Exception:
+                    print "Couldn't parse server response."
+                sys.exit(1)
             datum = json.loads(resp.read())
             for data in datum:
                 newversions.add(data['name'])
-        newversions.add(versions[0])
-        newversions.add(versions[-1])
-        newlist = newversions.copy()
-        newlist = list(newlist)
+        newlist = list(newversions.copy())
+        newlist.append(versions[0])
+        newlist.append(versions[-1])
         newlist.sort(key=LooseVersion)
-        for newversion in newlist[newlist.index(versions[0]):newlist.index(
-                versions[-1]) + 1]:
+        start_index = newlist.index(versions[0])
+        end_index = len(newlist) - 1 - newlist[::-1].index(versions[-1])
+        for newversion in newlist[start_index + 1:end_index]:
             if newversion in newversions:
                 print "Adding %s to the list" % newversion
                 self.newversions.append(newversion)
@@ -325,8 +338,14 @@ class JiraIter(object):
         except urllib2.HTTPError, err:
             code = err.code
             print "JIRA returns HTTP error %d: %s. Aborting." % (code, err.msg)
-            if code == 400:
-                print "Please make sure the specified projects are correct."
+            error_response = err.read()
+            try:
+                error_response = json.loads(error_response)
+                print "- Please ensure that specified projects, fixVersions etc. are correct."
+                for message in error_response['errorMessages']:
+                    print "-", message
+            except Exception:
+                print "Couldn't parse server response."
             sys.exit(1)
         except httplib.BadStatusLine as err:
             return JiraIter.retry_load(err, params, fail_count)


Mime
View raw message