mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
add github support
This commit is contained in:
parent
96368ade49
commit
c60639be51
2 changed files with 17 additions and 1 deletions
|
@ -11,7 +11,7 @@ import tornado.process
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
handler_precedence = ('aur', 'cmd', 'regex')
|
handler_precedence = ('github', 'aur', 'cmd', 'regex')
|
||||||
|
|
||||||
def get_version(name, conf, callback):
|
def get_version(name, conf, callback):
|
||||||
g = globals()
|
g = globals()
|
||||||
|
@ -60,6 +60,19 @@ def _aur_done(name, callback, res):
|
||||||
version = data['results']['Version']
|
version = data['results']['Version']
|
||||||
callback(name, 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 = queue.Queue()
|
||||||
cmd_q.running = False
|
cmd_q.running = False
|
||||||
|
|
||||||
|
|
|
@ -18,3 +18,6 @@ aur = python-you-get-git
|
||||||
|
|
||||||
[fbcat]
|
[fbcat]
|
||||||
aur
|
aur
|
||||||
|
|
||||||
|
[winterpy]
|
||||||
|
github = lilydjwg/winterpy
|
||||||
|
|
Loading…
Add table
Reference in a new issue