8
8
import textwrap
9
9
10
10
import requests
11
+ import requests_cache
11
12
from functools import reduce
12
13
13
14
GOOGLE_CHART_URL = 'https://chart.apis.google.com/chart'
14
15
MAX_SUMMARY_LENGTH = 30
15
16
17
+ cached_requests = requests_cache .CachedSession ('jira_cache' )
16
18
17
19
def log (* args ):
18
20
print (* args , file = sys .stderr )
@@ -36,9 +38,9 @@ def get(self, uri, params={}):
36
38
url = self .url + uri
37
39
38
40
if isinstance (self .auth , str ):
39
- return requests .get (url , params = params , cookies = {'JSESSIONID' : self .auth }, headers = headers , verify = self .no_verify_ssl )
41
+ return cached_requests .get (url , params = params , cookies = {'JSESSIONID' : self .auth }, headers = headers , verify = self .no_verify_ssl )
40
42
else :
41
- return requests .get (url , params = params , auth = self .auth , headers = headers , verify = (not self .no_verify_ssl ))
43
+ return cached_requests .get (url , params = params , auth = self .auth , headers = headers , verify = (not self .no_verify_ssl ))
42
44
43
45
def get_issue (self , key ):
44
46
""" Given an issue key (i.e. JRA-9) return the JSON representation of it. This is the only place where we deal
@@ -255,6 +257,7 @@ def parse_args():
255
257
parser .add_argument ('-t' , '--ignore-subtasks' , action = 'store_true' , default = False , help = 'Don' 't include sub-tasks issues' )
256
258
parser .add_argument ('-T' , '--dont-traverse' , dest = 'traverse' , action = 'store_false' , default = True , help = 'Do not traverse to other projects' )
257
259
parser .add_argument ('-w' , '--word-wrap' , dest = 'word_wrap' , default = False , action = 'store_true' , help = 'Word wrap issue summaries instead of truncating them' )
260
+ parser .add_argument ('-a' , '--clear-cache' , dest = 'clear_cache' , default = False , action = 'store_true' , help = 'Clear requests cache' )
258
261
parser .add_argument ('-b' , '--show-assignee' , dest = 'show_assignee' , default = False , action = 'store_true' , help = 'Show assignee in issues' )
259
262
parser .add_argument ('--no-verify-ssl' , dest = 'no_verify_ssl' , default = False , action = 'store_true' , help = 'Don\' t verify SSL certs for requests' )
260
263
parser .add_argument ('issues' , nargs = '*' , help = 'The issue key (e.g. JRADEV-1107, JRADEV-1391)' )
@@ -286,6 +289,9 @@ def main():
286
289
else getpass .getpass ('Password: ' )
287
290
auth = (user , password )
288
291
292
+ if options .clear_cache is True :
293
+ cached_requests .cache .clear ()
294
+
289
295
jira = JiraSearch (options .jira_url , auth , options .no_verify_ssl )
290
296
291
297
if options .jql_query is not None :
0 commit comments