From: Zac Medico Date: Mon, 5 Sep 2011 00:58:44 +0000 (-0700) Subject: Update unread news items in --pretend mode. X-Git-Tag: v2.2.0_alpha54~10 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8539b5778f1cea24aab4ff47b1b65516c254de1f;p=portage.git Update unread news items in --pretend mode. This has been disabled since commit c7faa634369e61b87a40172ceb0a5cb9494fd518, but the only reason cited was to avoid permissions issues. So, go ahead and enable it, and handle PermissionDenied just in case. NOTE: The NewsManager typically handles permission errors by returning silently, so PermissionDenied won't necessarily be raised even if we do trigger a permission error. --- diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index 3477c19d8..82adca794 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -30,7 +30,7 @@ from portage.const import _ENABLE_DYN_LINK_MAP, _ENABLE_SET_CONFIG from portage.dbapi.dep_expand import dep_expand from portage.dbapi._expand_new_virt import expand_new_virt from portage.dep import Atom, extended_cp_match -from portage.exception import InvalidAtom +from portage.exception import InvalidAtom, PermissionDenied from portage.output import blue, bold, colorize, create_color_func, darkgreen, \ red, yellow good = create_color_func("GOOD") @@ -3049,13 +3049,26 @@ def display_news_notification(root_config, myopts): NEWS_PATH = os.path.join("metadata", "news") UNREAD_PATH = os.path.join(target_root, NEWS_LIB_PATH, "news") newsReaderDisplay = False - update = "--pretend" not in myopts if "news" not in settings.features: return + permission_msgs = set() for repo in portdb.getRepositories(): - unreadItems = checkUpdatedNewsItems( - portdb, vardb, NEWS_PATH, UNREAD_PATH, repo, update=update) + try: + unreadItems = checkUpdatedNewsItems( + portdb, vardb, NEWS_PATH, UNREAD_PATH, repo, update=True) + except PermissionDenied as e: + # NOTE: The NewsManager typically handles permission errors by + # returning silently, so PermissionDenied won't necessarily be + # raised even if we do trigger a permission error above. + msg = _unicode_decode("Permission denied: '%s'\n") % (e,) + if msg in permission_msgs: + pass + else: + permission_msgs.add(msg) + writemsg_level(msg, level=logging.ERROR, noiselevel=-1) + unreadItems = None + if unreadItems: if not newsReaderDisplay: newsReaderDisplay = True