ATLAS Offline Software
Loading...
Searching...
No Matches
python.scripts.jira_issues Namespace Reference

Functions

 queryJira (querystring, cookies)
 functions --------------------------------------------------------------—
 main (args)

Variables

str __doc__ = "Interface with CERN JIRA instance."
str __author__ = "Edward Moyse"

Function Documentation

◆ main()

python.scripts.jira_issues.main ( args)
Interface to the CERN JIRA instance

Definition at line 56 of file jira_issues.py.

56def main(args):
57 """Interface to the CERN JIRA instance"""
58
59 #authentication
60 try:
61 cookiesFile = open(args.cookies, 'r')
62 cookies = {}
63 for line in cookiesFile:
64 text = line.split()
65 if 'JSESSIONID' in line:
66 cookies['JSESSIONID'] = text[-1]
67 if 'atlassian.xsrf.token' in line:
68 cookies['atlassian.xsrf.token'] = text[-1]
69 except Exception:
70 print ("Problems opening cookie file at ", args.cookies)
71 return 1
72
73 querystring = ""
74 if (args.query):
75 print ("Will use the following search string: ",args.query)
76 querystring = args.query
77 else:
78 querystring = "search?jql=resolution=Unresolved"
79 if (args.myissues):
80 querystring += "+AND+assignee=currentUser()"
81 if (args.release):
82 querystring += "+AND+affectedVersion="+args.release
83 if (args.status):
84 querystring += "+AND+status="+args.status
85
86 response = queryJira(querystring, cookies)
87 if not response:
88 return 1
89
90 # Now lets get some information out
91 issues = response['issues']
92 print()
93 print ('Key'.ljust(20), 'Summary'.ljust(20))
94 print ('---'.ljust(20), '-------'.ljust(20))
95 for issue in issues:
96 print (issue['key'].ljust(20), issue['fields']['summary'].ljust(20))
97 return
98
99
100
void print(char *figname, TCanvas *c1)
int main()
Definition hello.cxx:18

◆ queryJira()

python.scripts.jira_issues.queryJira ( querystring,
cookies )

functions --------------------------------------------------------------—

Definition at line 19 of file jira_issues.py.

19def queryJira(querystring, cookies):
20 # Now, let's make this request!
21 base_url = "https://its.cern.ch/jira/rest/api/2/"
22 url = base_url+querystring
23
24 r = requests.get(url, cookies=cookies)
25 if r.status_code != 200:
26 if r.status_code == 401:
27 print ('Authorisation has failed. Have you got a valid SSO cookie? If not, re-run "cern-get-sso-cookie -u https://its.cern.ch/jira/loginCern.jsp -o jira.txt" ')
28 else:
29 print ("Something has gone wrong! The response is: ", r.text)
30 return
31
32 import json
33 response = json.loads(r.text)
34 return response
35
36@acmdlib.command(name='jira.issues')
37@acmdlib.argument('-c', '--cookies',
38 required=False,
39 default = 'jira.txt',
40 help='the CERN SSO cookies file')
41@acmdlib.argument('-r', '--release',
42 required=False,
43 help='Limit the response to the specified release')
44@acmdlib.argument('-m', '--myissues',
45 action='store_true',
46 default=True,
47 required=False,
48 help='Limit the response your own issues')
49@acmdlib.argument('-q', '--query',
50 required=False,
51 help='Use the specified query string i.e. "search?jql=assignee=currentUser()+and+resolution=Unresolved"')
52@acmdlib.argument('-s', '--status',
53 required=False,
54 help='Limit the search to issues with this status, e.g. "Open"')
55

Variable Documentation

◆ __author__

str python.scripts.jira_issues.__author__ = "Edward Moyse"
private

Definition at line 9 of file jira_issues.py.

◆ __doc__

str python.scripts.jira_issues.__doc__ = "Interface with CERN JIRA instance."
private

Definition at line 8 of file jira_issues.py.