mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
Use proxy settings if set for github and cpan repos
This commit is contained in:
parent
bd61be6981
commit
224e9f4b08
2 changed files with 21 additions and 2 deletions
|
@ -4,6 +4,7 @@ from functools import partial
|
|||
|
||||
from tornado.httpclient import AsyncHTTPClient, HTTPRequest
|
||||
|
||||
from .base import pycurl
|
||||
from ..sortversion import sort_version_keys
|
||||
|
||||
GITHUB_URL = 'https://api.github.com/repos/%s/commits?sha=%s'
|
||||
|
@ -26,7 +27,15 @@ def get_version(name, conf, callback):
|
|||
headers = {'Accept': "application/vnd.github.quicksilver-preview+json"}
|
||||
if 'NVCHECKER_GITHUB_TOKEN' in os.environ:
|
||||
headers['Authorization'] = 'token %s' % os.environ['NVCHECKER_GITHUB_TOKEN']
|
||||
request = HTTPRequest(url, headers=headers, user_agent='lilydjwg/nvchecker')
|
||||
|
||||
kwargs = {}
|
||||
if conf.get('proxy'):
|
||||
if pycurl:
|
||||
kwargs['proxy_host'] = "".join(conf['proxy'].split(':')[:-1])
|
||||
kwargs['proxy_port'] = int(conf['proxy'].split(':')[-1])
|
||||
else:
|
||||
logger.warn('%s: proxy set but not used because pycurl is unavailable.', name)
|
||||
request = HTTPRequest(url, headers=headers, user_agent='lilydjwg/nvchecker', **kwargs)
|
||||
AsyncHTTPClient().fetch(request,
|
||||
callback=partial(_github_done, name, use_latest_release, use_max_tag, ignored_tags, sort_version_key, callback))
|
||||
|
||||
|
|
|
@ -3,13 +3,23 @@ from functools import partial
|
|||
|
||||
from tornado.httpclient import AsyncHTTPClient
|
||||
|
||||
from .base import pycurl
|
||||
|
||||
def simple_json(urlpat, confkey, version_from_json):
|
||||
|
||||
def get_version(name, conf, callback):
|
||||
repo = conf.get(confkey) or name
|
||||
url = urlpat % repo
|
||||
kwargs = {}
|
||||
if conf.get('proxy'):
|
||||
if pycurl:
|
||||
kwargs['proxy_host'] = "".join(conf['proxy'].split(':')[:-1])
|
||||
kwargs['proxy_port'] = int(conf['proxy'].split(':')[-1])
|
||||
else:
|
||||
logger.warn('%s: proxy set but not used because pycurl is unavailable.', name)
|
||||
|
||||
AsyncHTTPClient().fetch(url, user_agent='lilydjwg/nvchecker',
|
||||
callback=partial(_json_done, name, callback))
|
||||
callback=partial(_json_done, name, callback), **kwargs)
|
||||
|
||||
def _json_done(name, callback, res):
|
||||
data = json.loads(res.body.decode('utf-8'))
|
||||
|
|
Loading…
Add table
Reference in a new issue