ATLAS Offline Software
Functions | Variables
python.scripts.jira_issues Namespace Reference

Functions

def queryJira (querystring, cookies)
 functions --------------------------------------------------------------— More...
 
def main (args)
 

Variables

 __doc__
 
 __author__
 

Function Documentation

◆ main()

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

Definition at line 58 of file jira_issues.py.

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

◆ queryJira()

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

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

Definition at line 21 of file jira_issues.py.

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

Variable Documentation

◆ __author__

python.scripts.jira_issues.__author__
private

Definition at line 11 of file jira_issues.py.

◆ __doc__

python.scripts.jira_issues.__doc__
private

Definition at line 10 of file jira_issues.py.

python.scripts.jira_issues.queryJira
def queryJira(querystring, cookies)
functions --------------------------------------------------------------—
Definition: jira_issues.py:21
python.scripts.jira_issues.main
def main(args)
Definition: jira_issues.py:58
Trk::open
@ open
Definition: BinningType.h:40
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70