Skip to content

Instantly share code, notes, and snippets.

@squito
Created January 16, 2018 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save squito/de73fbd0b9c00961377068b91283e04c to your computer and use it in GitHub Desktop.
Save squito/de73fbd0b9c00961377068b91283e04c to your computer and use it in GitHub Desktop.
SPARK-23044 session
# filters out "apachespark" choice now
# notice what happens with
# * bad input ("floop")
# * real user that can't be assigned a jira ("fakeimran")
# * selection from list ("imran")
# * arbitrary user that can be assigned ("vanzin")
In [1]: from merge_spark_pr import *
In [2]: asf_jira = jira.client.JIRA({'server': JIRA_API_BASE},
basic_auth=(JIRA_USERNAME, JIRA_PASSWORD))
In [4]: jira_id = "SPARK-12297"
In [5]: issue = asf_jira.issue(jira_id)
In [6]: x = choose_jira_assignee(issue, asf_jira); x.displayName if x else None
In [6]: x = choose_jira_assignee(issue, asf_jira); x.displayName if x else None [59/4715]
JIRA is unassigned, choose assignee
[0] Reynold Xin (Commentor)
[1] Zoltan Ivanfi (Commentor)
[2] Wenchen Fan (Commentor)
[3] Ryan Blue (Reporter,Commentor)
[4] Takuya Ueshin (Commentor)
[6] Hyukjin Kwon (Commentor)
[7] Imran Rashid (Commentor)
Enter number of user, or userid, to assign to (blank to leave unassigned):floop
Traceback (most recent call last):
File "merge_spark_pr.py", line 326, in choose_jira_assignee
assignee = asf_jira.user(raw_assignee)
File "/Library/Python/2.7/site-packages/jira/client.py", line 1655, in user
user.find(id, params=params)
File "/Library/Python/2.7/site-packages/jira/resources.py", line 157, in find
self._load(url, params=params)
File "/Library/Python/2.7/site-packages/jira/resources.py", line 259, in _load
r = self._session.get(url, headers=headers, params=params)
File "/Library/Python/2.7/site-packages/jira/resilientsession.py", line 130, in get
return self.__verb('GET', url, **kwargs)
File "/Library/Python/2.7/site-packages/jira/resilientsession.py", line 126, in __verb
raise_on_error(response, verb=verb, **kwargs)
File "/Library/Python/2.7/site-packages/jira/resilientsession.py", line 45, in raise_on_error
r.status_code, error, r.url, request=request, response=r, **kwargs)
JIRAError: JiraError HTTP 404
text: The user named 'floop' does not exist
url: https://issues.apache.org/jira/rest/api/2/user?username=floop
response headers = {'X-AUSERNAME': 'irashid', 'X-ASEN': 'SEN-2062203', 'X-XSS-Protection': '1; mode=block', 'Content-Security-Policy': "frame-ancestors 'self'", 'X-Content-Type-Options': 'nosni
ff', 'Transfer-Encoding': 'chunked', 'X-Seraph-LoginReason': 'OK', 'X-AREQUESTID': '1131x5053205x11', 'X-ASESSIONID': '1w2em6t', 'Connection': 'close', 'Cache-Control': 'no-cache, no-store, no-transfor
m', 'Date': 'Tue, 16 Jan 2018 18:51:13 GMT', 'X-Frame-Options': 'SAMEORIGIN', 'Server': 'Apache/2.4.18 (Ubuntu)', 'Content-Type': 'application/json;charset=UTF-8'}
response text = {"errorMessages":["The user named 'floop' does not exist"],"errors":{}}
Error assigning JIRA, try again (or leave blank and fix manually)
JIRA is unassigned, choose assignee
[0] Reynold Xin (Commentor)
[1] Zoltan Ivanfi (Commentor)
[2] Wenchen Fan (Commentor)
[3] Ryan Blue (Reporter,Commentor)
[4] Takuya Ueshin (Commentor)
[6] Hyukjin Kwon (Commentor)
[7] Imran Rashid (Commentor)
Enter number of user, or userid, to assign to (blank to leave unassigned):fakeimran
Traceback (most recent call last):
File "merge_spark_pr.py", line 327, in choose_jira_assignee
asf_jira.assign_issue(issue.key, assignee.key)
File "/Library/Python/2.7/site-packages/jira/client.py", line 93, in wrapper
result = func(*arg_list, **kwargs)
File "/Library/Python/2.7/site-packages/jira/client.py", line 831, in assign_issue
url, data=json.dumps(payload))
File "/Library/Python/2.7/site-packages/jira/resilientsession.py", line 136, in put
return self.__verb('PUT', url, **kwargs)
File "/Library/Python/2.7/site-packages/jira/resilientsession.py", line 126, in __verb
raise_on_error(response, verb=verb, **kwargs)
File "/Library/Python/2.7/site-packages/jira/resilientsession.py", line 45, in raise_on_error
r.status_code, error, r.url, request=request, response=r, **kwargs)
JIRAError: JiraError HTTP 400
text: User 'fakeimran' cannot be assigned issues.
url: https://issues.apache.org/jira/rest/api/2/issue/SPARK-12297/assignee
response headers = {'X-AUSERNAME': 'irashid', 'X-ASEN': 'SEN-2062203', 'X-XSS-Protection': '1; mode=block', 'Content-Security-Policy': "frame-ancestors 'self'", 'X-Content-Type-Options': 'nosni
ff', 'Transfer-Encoding': 'chunked', 'X-Seraph-LoginReason': 'OK', 'X-AREQUESTID': '1131x5053344x9', 'X-ASESSIONID': '1w2em6t', 'Connection': 'close', 'Cache-Control': 'no-cache, no-store, no-transform
', 'Date': 'Tue, 16 Jan 2018 18:51:16 GMT', 'X-Frame-Options': 'SAMEORIGIN', 'Server': 'Apache/2.4.18 (Ubuntu)', 'Content-Type': 'application/json;charset=UTF-8'}
response text = {"errorMessages":[],"errors":{"assignee":"User 'fakeimran' cannot be assigned issues."}}
Error assigning JIRA, try again (or leave blank and fix manually)
JIRA is unassigned, choose assignee
[0] Reynold Xin (Commentor)
[1] Zoltan Ivanfi (Commentor)
[2] Wenchen Fan (Commentor)
[3] Ryan Blue (Reporter,Commentor)
[4] Takuya Ueshin (Commentor)
[6] Hyukjin Kwon (Commentor)
[7] Imran Rashid (Commentor)
Enter number of user, or userid, to assign to (blank to leave unassigned):vanzin
Out[6]: u'Marcelo Vanzin'
In [7]:
In [7]: x = choose_jira_assignee(issue, asf_jira); x.displayName if x else None
JIRA is unassigned, choose assignee
[0] Reynold Xin (Commentor)
[1] Zoltan Ivanfi (Commentor)
[2] Wenchen Fan (Commentor)
[3] Ryan Blue (Reporter,Commentor)
[4] Takuya Ueshin (Commentor)
[6] Hyukjin Kwon (Commentor)
[7] Imran Rashid (Commentor)
Enter number of user, or userid, to assign to (blank to leave unassigned):
In [8]: str(x)
Out[8]: 'None'
In [9]: x = choose_jira_assignee(issue, asf_jira); x.displayName if x else None
JIRA is unassigned, choose assignee
[0] Reynold Xin (Commentor)
[1] Zoltan Ivanfi (Commentor)
[2] Wenchen Fan (Commentor)
[3] Ryan Blue (Reporter,Commentor)
[4] Takuya Ueshin (Commentor)
[6] Hyukjin Kwon (Commentor)
[7] Imran Rashid (Commentor)
Enter number of user, or userid, to assign to (blank to leave unassigned):7
Out[9]: u'Imran Rashid'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment