From 16ef913b8886e76774ced05d31e2326c5b832ccf Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Sun, 3 Nov 2013 18:50:19 +0800 Subject: [PATCH] fix exception when AUR package disappears --- nvchecker/main.py | 4 ++++ nvchecker/source/aur.py | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/nvchecker/main.py b/nvchecker/main.py index 02632aa..4bec19a 100755 --- a/nvchecker/main.py +++ b/nvchecker/main.py @@ -46,6 +46,10 @@ def write_verfile(): util.write_verfile(args.newver, g_curver) def print_version_update(name, version): + if version is None: + task_dec() + return + oldver = g_oldver.get(name, None) if not oldver or parse_version(oldver) < parse_version(version): logger.info('%s: updated version %s', name, version) diff --git a/nvchecker/source/aur.py b/nvchecker/source/aur.py index d29baf5..f4ca365 100644 --- a/nvchecker/source/aur.py +++ b/nvchecker/source/aur.py @@ -1,10 +1,13 @@ from functools import partial import json +import logging from tornado.httpclient import AsyncHTTPClient AUR_URL = 'https://aur.archlinux.org/rpc.php?type=info&arg=' +logger = logging.getLogger(__name__) + def get_version(name, conf, callback): aurname = conf.get('aur') or name url = AUR_URL + aurname @@ -12,5 +15,11 @@ def get_version(name, conf, callback): def _aur_done(name, callback, res): data = json.loads(res.body.decode('utf-8')) + + if not data['results']: + logger.error('AUR upstream not found for %s', name) + callback(name, None) + return + version = data['results']['Version'] callback(name, version)