Skip to content

Commit a3e1834

Browse files
authored
Merge branch 'master' into support_tz_aware_datetime_objects
2 parents 5e51951 + b362022 commit a3e1834

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

codespeed/commits/github.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@
1111
try:
1212
# Python 3
1313
from urllib.request import urlopen
14+
from urllib.request import Request
1415
except ImportError:
1516
# Python 2
16-
from urllib import urlopen
17+
from urllib2 import urlopen
18+
from urllib2 import Request
1719
import re
1820
import json
1921

2022
import isodate
23+
from django.conf import settings
2124
from django.core.cache import cache
2225
from django.conf import settings
2326

@@ -43,8 +46,17 @@ def fetch_json(url):
4346
json_obj = cache.get(url)
4447

4548
if json_obj is None:
49+
github_oauth_token = getattr(settings, 'GITHUB_OAUTH_TOKEN', None)
50+
51+
if github_oauth_token:
52+
headers = {'Authorization': 'token %s' % (github_oauth_token)}
53+
else:
54+
headers = {}
55+
56+
request = Request(url=url, headers=headers)
57+
4658
try:
47-
json_obj = json.load(urlopen(url))
59+
json_obj = json.load(urlopen(request))
4860
except IOError as e:
4961
logger.exception("Unable to load %s: %s",
5062
url, e, exc_info=True)

codespeed/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,7 @@
8686

8787
US_TZ_AWARE_DATES = False # True to use timezone aware datetime objects with Github provider.
8888
# NOTE: Some database backends may not support tz aware dates.
89+
90+
GITHUB_OAUTH_TOKEN = None # Github oAuth token to use when using Github repo type. If not
91+
# specified, it will utilize unauthenticated requests which have
92+
# low rate limits.

codespeed/templates/codespeed/timeline.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
{% block extra_head %}
88
{{ block.super }}
9-
<link rel="stylesheet" type="text/css" href="{% static '/css/timeline.css' %}" />
9+
<link rel="stylesheet" type="text/css" href="{% static 'css/timeline.css' %}" />
1010
<link rel="stylesheet" type="text/css" href="{% static 'js/jqplot/jquery.jqplot.min.css' %}" />
1111
{% endblock %}
1212

0 commit comments

Comments
 (0)