summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordol-sen2011-10-27 04:42:21 (GMT)
committerdol-sen2011-10-27 04:42:21 (GMT)
commitad38a35a994b32ea65df5395d78a9ffabe9773e4 (patch)
treea3ab960cc2f802e920ecc2f626c3eccafcec8ad1
parentc40874bd95d1525961692dd7d742ed565a2b4334 (diff)
update portage news reporting to use the new public api functions.
-rwxr-xr-xlayman/api.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/layman/api.py b/layman/api.py
index cbf70e6..4ff62dd 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -544,18 +544,32 @@ class LaymanAPI(object):
def update_news(self, repos=None):
try:
if self.config['news_reporter'] == 'portage':
- from _emerge.actions import (display_news_notification,
- load_emerge_config)
- settings, trees, mtimedb = load_emerge_config()
- display_news_notification(trees[settings["ROOT"]]["root_config"],
- {"news_repos": repos})
+ try:
+ from portage import db, root
+ from portage.news import count_unread_news, \
+ display_news_notifications
+ portdb = db[root]["porttree"].dbapi
+ vardb = db[root]["vartree"].dbapi
+ news_counts = count_unread_news(portdb, vardb, repos)
+ display_news_notifications(news_counts)
+ except ImportError:
+ # deprecated funtionality, remove when the above method
+ # is available in all portage versions
+ self.output.info("New portage news functionality not "
+ "available, using fallback method", 5)
+ from _emerge.actions import (display_news_notification,
+ load_emerge_config)
+ settings, trees, mtimedb = load_emerge_config()
+ display_news_notification(
+ trees[settings["ROOT"]]["root_config"], {})
elif self.config['news_reporter'] == 'custom':
self.config['custom_news_func'](repos)
elif self.config['news_reporter'] == 'pkgcore':
return
- except:
- self._error("update_news() failed running %s news reporter function"
- % self.config['news_reporter'])
+ except Exception as err:
+ msg = "update_news() failed running %s news reporter function\n" +\
+ "Error was; %s"
+ self._error(msg % (self.config['news_reporter'], err))
return