mirror of
https://github.com/lilydjwg/nvchecker
synced 2025-01-30 18:13:12 +00:00
add github support
This commit is contained in:
parent
96368ade49
commit
c60639be51
@ -11,7 +11,7 @@ import tornado.process
|
||||
from tornado.ioloop import IOLoop
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
handler_precedence = ('aur', 'cmd', 'regex')
|
||||
handler_precedence = ('github', 'aur', 'cmd', 'regex')
|
||||
|
||||
def get_version(name, conf, callback):
|
||||
g = globals()
|
||||
@ -60,6 +60,19 @@ def _aur_done(name, callback, res):
|
||||
version = data['results']['Version']
|
||||
callback(name, version)
|
||||
|
||||
GITHUB_URL = 'https://api.github.com/repos/%s/commits'
|
||||
|
||||
def get_version_by_github(name, conf, callback):
|
||||
repo = conf.get('github')
|
||||
url = GITHUB_URL % repo
|
||||
AsyncHTTPClient().fetch(url, user_agent='lilydjwg/nvchecker',
|
||||
callback=partial(_github_done, name, callback))
|
||||
|
||||
def _github_done(name, callback, res):
|
||||
data = json.loads(res.body.decode('utf-8'))
|
||||
version = data[0]['commit']['committer']['date'].split('T', 1)[0].replace('-', '')
|
||||
callback(name, version)
|
||||
|
||||
cmd_q = queue.Queue()
|
||||
cmd_q.running = False
|
||||
|
||||
|
@ -18,3 +18,6 @@ aur = python-you-get-git
|
||||
|
||||
[fbcat]
|
||||
aur
|
||||
|
||||
[winterpy]
|
||||
github = lilydjwg/winterpy
|
||||
|
Loading…
Reference in New Issue
Block a user