add AUR support
This commit is contained in:
parent
4120bcb28c
commit
96368ade49
|
@ -3,6 +3,7 @@ import sre_constants
|
|||
import logging
|
||||
from functools import partial
|
||||
import queue
|
||||
import json
|
||||
|
||||
from pkg_resources import parse_version
|
||||
from tornado.httpclient import AsyncHTTPClient
|
||||
|
@ -10,7 +11,7 @@ import tornado.process
|
|||
from tornado.ioloop import IOLoop
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
handler_precedence = ('cmd', 'regex')
|
||||
handler_precedence = ('aur', 'cmd', 'regex')
|
||||
|
||||
def get_version(name, conf, callback):
|
||||
g = globals()
|
||||
|
@ -47,6 +48,18 @@ def _get_version_by_regex(name, regex, encoding, callback, res):
|
|||
else:
|
||||
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.running = False
|
||||
|
||||
|
|
|
@ -12,3 +12,9 @@ regex = 7\.3\.\d+
|
|||
|
||||
[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}'
|
||||
|
||||
[you-get]
|
||||
aur = python-you-get-git
|
||||
|
||||
[fbcat]
|
||||
aur
|
||||
|
|
Loading…
Reference in New Issue