File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111try :
1212 # Python 3
1313 from urllib .request import urlopen
14+ from urllib .request import Request
1415except ImportError :
1516 # Python 2
16- from urllib import urlopen
17+ from urllib2 import urlopen
18+ from urllib2 import Request
1719import re
1820import json
1921
2022import isodate
23+ from django .conf import settings
2124from django .core .cache import cache
2225
2326from .exceptions import CommitLogError
@@ -42,8 +45,17 @@ def fetch_json(url):
4245 json_obj = cache .get (url )
4346
4447 if json_obj is None :
48+ github_oauth_token = getattr (settings , 'GITHUB_OAUTH_TOKEN' , None )
49+
50+ if github_oauth_token :
51+ headers = {'Authorization' : 'token %s' % (github_oauth_token )}
52+ else :
53+ headers = {}
54+
55+ request = Request (url = url , headers = headers )
56+
4557 try :
46- json_obj = json .load (urlopen (url ))
58+ json_obj = json .load (urlopen (request ))
4759 except IOError as e :
4860 logger .exception ("Unable to load %s: %s" ,
4961 url , e , exc_info = True )
Original file line number Diff line number Diff line change 8383
8484ALLOW_ANONYMOUS_POST = True # Whether anonymous users can post results
8585REQUIRE_SECURE_AUTH = True # Whether auth needs to be over a secure channel
86+
87+ GITHUB_OAUTH_TOKEN = None # Github oAuth token to use when using Github repo type. If not
88+ # specified, it will utilize unauthenticated requests which have
89+ # low rate limits.
You can’t perform that action at this time.
0 commit comments