[asterisk-commits] digium jira user: Handle users extracted from JIRA better (repotools[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 9 18:02:59 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: digium_jira_user: Handle users extracted from JIRA better
......................................................................


digium_jira_user: Handle users extracted from JIRA better

This patch makes handling users extracted from JIRA slightly better by
doing the following:
1) All usernames are now explicitly cast to str() objects. This prevents
   two usernames that are semantically the same from being miscompared
   due to one being a str object and the other being a unicode object.
   Note that it is generally safer to make things str objects and encode
   them as unicode when printing, as this provides a single point in
   time in which the encoding occurs.
2) We now try to catch exceptions from JIRA and - if JIRA fails - return
   a basic AsteriskUser object. This prevents errors in a commit message
   from blowing out scripts completely.

As well, this patch adds a few more name mappings to try and prevent
duplicate reporting.

Change-Id: I636cbb0b683c7d0589cdcb6df23faf0abc6dc33c
---
M digium_jira_user.py
1 file changed, 12 insertions(+), 8 deletions(-)

Approvals:
  Mark Michelson: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Verified



diff --git a/digium_jira_user.py b/digium_jira_user.py
index 0b2e1f4..da42e6c 100644
--- a/digium_jira_user.py
+++ b/digium_jira_user.py
@@ -5,8 +5,6 @@
 Matt Jordan <mjordan at digium.com>
 """
 
-import getpass
-
 from digium_jira import get_jira_client
 
 # A mapping of known organizations to usernames
@@ -16,7 +14,7 @@
                'mspiceland', 'sruffell', 'espiceland', 'rmudgett',
                'mjordan', 'jrose', 'kmoore', 'jcolp', 'jbigelow', 'dlee',
                'mdavenport', 'rnewton', 'sgriepentrog', 'sgalarneau',
-               'rmeyerriecks', 'dbailey', 'jhardin', 'asanders',],
+               'rmeyerriecks', 'dbailey', 'jhardin', 'asanders', ],
     'Xorcom': ['tzafrir', 'leonidf', 'diegoias', 'dennis-xorcom'],
     'Sangoma': ['jparker', 'moy', 'dyatsin', 'tm1000', 'jameswf',
                 'p_lindheimer', 'schmoozecom'],
@@ -41,7 +39,11 @@
     'opticron': 'kmoore',
     'file': 'jcolp',
     'andrewsnagy': 'tm1000',
-    'TheJames': 'jameswf', }
+    'TheJames': 'jameswf',
+    'Corey Farrell': 'coreyfarrell',
+    'Matt Jordan': 'mjordan',
+    'Matthew Jordan': 'mjordan',
+    'George Joseph': 'gtjoseph', }
 
 
 class AsteriskUser(object):
@@ -68,7 +70,7 @@
         self.jira_user_obj = None
         self.organization = None
 
-        self.username = username
+        self.username = str(username)
 
     @property
     def username(self):
@@ -146,7 +148,10 @@
     if not jira:
         jira = get_jira_client()
 
-    jira_user = jira.user(user.username)
+    try:
+        jira_user = jira.user(user.username)
+    except:
+        return user
     if not jira_user:
         return user
 
@@ -157,9 +162,8 @@
     if issue:
         jira_issue = jira.issue(issue)
         attachments = filter(lambda a: a.raw['author']['name'] == username,
-                jira_issue.fields.attachment)
+                             jira_issue.fields.attachment)
         if len(attachments) != 0:
             attachment = jira.attachment(attachments[0].id)
             user.license = attachment.raw['properties']['license']
     return user
-

-- 
To view, visit https://gerrit.asterisk.org/609
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I636cbb0b683c7d0589cdcb6df23faf0abc6dc33c
Gerrit-PatchSet: 1
Gerrit-Project: repotools
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list