From f1ac6fc5b697632d4db04265bc0c0ec6554e6855 Mon Sep 17 00:00:00 2001 From: dol-sen Date: Fri, 19 Aug 2011 18:08:43 -0700 Subject: fix success reporting identified in bug 379779. Improve and change error output from info(), warn() to error(). --- layman/api.py | 4 ++-- layman/db.py | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'layman') diff --git a/layman/api.py b/layman/api.py index cfd9a68..7894c56 100755 --- a/layman/api.py +++ b/layman/api.py @@ -441,7 +441,7 @@ class LaymanAPI(object): """ try: - dbreload = self._get_remote_db().cache() + dbreload, succeeded = self._get_remote_db().cache() self.output.debug( 'LaymanAPI.fetch_remote_list(); cache updated = %s' % str(dbreload),8) @@ -450,7 +450,7 @@ class LaymanAPI(object): + str(error)) return False self.get_available(dbreload) - return True + return succeeded def get_available(self, dbreload=False): diff --git a/layman/db.py b/layman/db.py index bd58cd6..08af0f6 100644 --- a/layman/db.py +++ b/layman/db.py @@ -288,7 +288,7 @@ class RemoteDB(DbBase): >>> config.set_option('quietness', 3) >>> a = RemoteDB(config) >>> a.cache() - True + (True, True) >>> b = open(a.filepath(config['overlays'])+'.xml') >>> b.readlines()[24] ' A collection of ebuilds from Gunnar Wrobel [wrobel@gentoo.org].\\n' @@ -300,6 +300,8 @@ class RemoteDB(DbBase): [u'wrobel', u'wrobel-stable'] ''' has_updates = False + # succeeded reset when a failure is detected + succeeded = True for url in self.urls: filepath = self.filepath(url) @@ -334,12 +336,17 @@ class RemoteDB(DbBase): % url, 4) self.output.info('Last-modified: %s' % timestamp, 4) else: - self.output.info('RemoteDB.cache(); HTTPError was:\n %s' - % str(e)) + self.output.error('RemoteDB.cache(); HTTPError was:\n' + 'url: %s\n%s' + % (url, str(e))) + succeeded = False continue except IOError, error: - self.output.warn('RemoteDB.cache(); Failed to update the overlay list from: ' - + url + '\nIOError was:\n' + str(error)) + self.output.error('RemoteDB.cache(); Failed to update the ' + 'overlay list from: %s\nIOError was:%s\n' + % (url, str(error))) + succeeded = False + continue else: if url.startswith('file://'): quieter = 1 @@ -387,7 +394,9 @@ class RemoteDB(DbBase): except Exception, error: raise IOError('Failed to temporarily cache overlays list in' ' ' + mpath + '\nError was:\n' + str(error)) - return has_updates + self.output.debug("RemoteDB.cache() returning: has_updates, succeeded" + " %s, %s" % (str(has_updates), str(succeeded)), 4) + return has_updates, succeeded def filepath(self, url): -- cgit v1.2.3-1-g7c22