add AUR support

This commit is contained in:
lilydjwg 2013-07-01 17:41:01 +08:00
parent 4120bcb28c
commit 96368ade49
2 changed files with 20 additions and 1 deletions

View File

@ -3,6 +3,7 @@ import sre_constants
import logging import logging
from functools import partial from functools import partial
import queue import queue
import json
from pkg_resources import parse_version from pkg_resources import parse_version
from tornado.httpclient import AsyncHTTPClient from tornado.httpclient import AsyncHTTPClient
@ -10,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 = ('cmd', 'regex') handler_precedence = ('aur', 'cmd', 'regex')
def get_version(name, conf, callback): def get_version(name, conf, callback):
g = globals() g = globals()
@ -47,6 +48,18 @@ def _get_version_by_regex(name, regex, encoding, callback, res):
else: else:
callback(name, version) callback(name, version)
AUR_URL = 'https://aur.archlinux.org/rpc.php?type=info&arg='
def get_version_by_aur(name, conf, callback):
aurname = conf.get('aur') or name
url = AUR_URL + aurname
AsyncHTTPClient().fetch(url, partial(_aur_done, name, callback))
def _aur_done(name, callback, res):
data = json.loads(res.body.decode('utf-8'))
version = data['results']['Version']
callback(name, version)
cmd_q = queue.Queue() cmd_q = queue.Queue()
cmd_q.running = False cmd_q.running = False

View File

@ -12,3 +12,9 @@ regex = 7\.3\.\d+
[google-chrome] [google-chrome]
cmd = wget -qO- http://dl.google.com/linux/chrome/rpm/stable/x86_64/repodata/other.xml.gz | zgrep "google-chrome-stable" | awk -F\" '{print $10"-"$12}' cmd = wget -qO- http://dl.google.com/linux/chrome/rpm/stable/x86_64/repodata/other.xml.gz | zgrep "google-chrome-stable" | awk -F\" '{print $10"-"$12}'
[you-get]
aur = python-you-get-git
[fbcat]
aur