Merge pull request #4 from farseerfc/master
add access_token for github api, use NVCHECKER_GITHUB_TOKEN env var
This commit is contained in:
commit
388889a27e
|
@ -1,7 +1,8 @@
|
|||
import os
|
||||
import json
|
||||
from functools import partial
|
||||
|
||||
from tornado.httpclient import AsyncHTTPClient
|
||||
from tornado.httpclient import AsyncHTTPClient, HTTPRequest
|
||||
|
||||
GITHUB_URL = 'https://api.github.com/repos/%s/commits?sha=%s'
|
||||
|
||||
|
@ -9,7 +10,11 @@ def get_version(name, conf, callback):
|
|||
repo = conf.get('github')
|
||||
br = conf.get('branch', 'master')
|
||||
url = GITHUB_URL % (repo, br)
|
||||
AsyncHTTPClient().fetch(url, user_agent='lilydjwg/nvchecker',
|
||||
headers = {}
|
||||
if 'NVCHECKER_GITHUB_TOKEN' in os.environ:
|
||||
headers = {'Authorization': 'token %s' % os.environ['NVCHECKER_GITHUB_TOKEN']}
|
||||
request = HTTPRequest(url, headers=headers)
|
||||
AsyncHTTPClient().fetch(request, user_agent='lilydjwg/nvchecker',
|
||||
callback=partial(_github_done, name, callback))
|
||||
|
||||
def _github_done(name, callback, res):
|
||||
|
|
Loading…
Reference in New Issue