github: use keyfile

This commit is contained in:
lilydjwg 2018-05-05 23:44:50 +08:00
parent a73314dc64
commit 82dba4a965
2 changed files with 5 additions and 1 deletions

View File

@ -145,7 +145,7 @@ class Source:
async def worker(name, conf): async def worker(name, conf):
await token_q.get() await token_q.get()
try: try:
ret = await get_version(name, conf) ret = await get_version(name, conf, keyman=self.keymanager)
return name, ret return name, ret
except Exception as e: except Exception as e:
return name, e return name, e

View File

@ -38,6 +38,10 @@ async def get_version(name, conf, **kwargs):
} }
if 'NVCHECKER_GITHUB_TOKEN' in os.environ: if 'NVCHECKER_GITHUB_TOKEN' in os.environ:
headers['Authorization'] = 'token %s' % os.environ['NVCHECKER_GITHUB_TOKEN'] headers['Authorization'] = 'token %s' % os.environ['NVCHECKER_GITHUB_TOKEN']
else:
key = kwargs['keyman'].get_key('github')
if key:
headers['Authorization'] = 'token %s' % key
kwargs = {} kwargs = {}
if conf.get('proxy'): if conf.get('proxy'):