mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
add PyPI support
API: https://wiki.python.org/moin/PyPIJSON?action=show&redirect=PyPiJson
This commit is contained in:
parent
110d083bb9
commit
27df5909e3
2 changed files with 17 additions and 1 deletions
|
@ -12,7 +12,7 @@ import tornado.process
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
handler_precedence = ('github', 'aur', 'cmd', 'regex')
|
handler_precedence = ('github', 'aur', 'pypi', 'cmd', 'regex')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pycurl
|
import pycurl
|
||||||
|
@ -122,3 +122,16 @@ def _command_done(name, callback, process, status):
|
||||||
def _got_version_from_cmd(callback, name, output):
|
def _got_version_from_cmd(callback, name, output):
|
||||||
output = output.strip().decode('latin1')
|
output = output.strip().decode('latin1')
|
||||||
callback(name, output)
|
callback(name, output)
|
||||||
|
|
||||||
|
PYPI_URL = 'https://pypi.python.org/pypi/%s/json'
|
||||||
|
|
||||||
|
def get_version_by_pypi(name, conf, callback):
|
||||||
|
repo = conf.get('pypi') or name
|
||||||
|
url = PYPI_URL % repo
|
||||||
|
AsyncHTTPClient().fetch(url, user_agent='lilydjwg/nvchecker',
|
||||||
|
callback=partial(_pypi_done, name, callback))
|
||||||
|
|
||||||
|
def _pypi_done(name, callback, res):
|
||||||
|
data = json.loads(res.body.decode('utf-8'))
|
||||||
|
version = data['info']['version']
|
||||||
|
callback(name, version)
|
||||||
|
|
|
@ -29,3 +29,6 @@ github = lilydjwg/nvchecker
|
||||||
url = http://sed.sourceforge.net/grabbag/ssed/
|
url = http://sed.sourceforge.net/grabbag/ssed/
|
||||||
regex = The current version is ([\d.]+)\.
|
regex = The current version is ([\d.]+)\.
|
||||||
proxy = localhost:8087
|
proxy = localhost:8087
|
||||||
|
|
||||||
|
[PySide]
|
||||||
|
pypi = PySide
|
||||||
|
|
Loading…
Add table
Reference in a new issue