add github support

This commit is contained in:
lilydjwg 2013-07-01 17:45:10 +08:00
parent 96368ade49
commit c60639be51
2 changed files with 17 additions and 1 deletions

View File

@ -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

View File

@ -18,3 +18,6 @@ aur = python-you-get-git
[fbcat]
aur
[winterpy]
github = lilydjwg/winterpy