public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] Offer to read news while calcing deps (bug 517310)
@ 2014-08-01 20:02 Alexander Berntsen
  2014-09-22 11:26 ` Alexander Berntsen
  2014-09-22 11:48 ` [gentoo-portage-dev] [PATCHv3] " Alexander Berntsen
  0 siblings, 2 replies; 4+ messages in thread
From: Alexander Berntsen @ 2014-08-01 20:02 UTC (permalink / raw
  To: gentoo-portage-dev

Signed-off-by: Alexander Berntsen <bernalex@gentoo.org>
---
I don't have time for any more playing with this. Please test it, and
ACK it if it is OK. I will merge it when I get back if it's OK. :-]

 pym/_emerge/actions.py     | 10 ++++++++--
 pym/_emerge/post_emerge.py |  5 ++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index b935139..45f9167 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -4058,8 +4058,14 @@ def run_action(emerge_config):
 
 		# GLEP 42 says to display news *after* an emerge --pretend
 		if "--pretend" not in emerge_config.opts:
-			display_news_notification(
-				emerge_config.target_config, emerge_config.opts)
+			uq = UserQuery(emerge_config.opts)
+			if display_news_notification(emerge_config.target_config,
+								emerge_config.opts) \
+				and "--ask" in emerge_config.opts \
+				and uq.query("Would you like to read the news items while" \
+						"calculating dependencies?",
+						'--ask-enter-invalid' in emerge_config.opts) == "Yes":
+					subprocess.call(['eselect', 'news', 'read'])
 		retval = action_build(emerge_config.target_config.settings,
 			emerge_config.trees, emerge_config.target_config.mtimedb,
 			emerge_config.opts, emerge_config.action,
diff --git a/pym/_emerge/post_emerge.py b/pym/_emerge/post_emerge.py
index d5f1ba5..0cb533c 100644
--- a/pym/_emerge/post_emerge.py
+++ b/pym/_emerge/post_emerge.py
@@ -37,11 +37,14 @@ def clean_logs(settings):
 
 def display_news_notification(root_config, myopts):
 	if "news" not in root_config.settings.features:
-		return
+		return False
 	portdb = root_config.trees["porttree"].dbapi
 	vardb = root_config.trees["vartree"].dbapi
 	news_counts = count_unread_news(portdb, vardb)
+	if all(v == 0 for v in news_counts.values()):
+		return False
 	display_news_notifications(news_counts)
+	return True
 
 def show_depclean_suggestion():
 	out = portage.output.EOutput()
-- 
1.8.5.5



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-portage-dev] [PATCH] Offer to read news while calcing deps (bug 517310)
  2014-08-01 20:02 [gentoo-portage-dev] [PATCH] Offer to read news while calcing deps (bug 517310) Alexander Berntsen
@ 2014-09-22 11:26 ` Alexander Berntsen
  2014-09-22 11:48 ` [gentoo-portage-dev] [PATCHv3] " Alexander Berntsen
  1 sibling, 0 replies; 4+ messages in thread
From: Alexander Berntsen @ 2014-09-22 11:26 UTC (permalink / raw
  To: gentoo-portage-dev

Signed-off-by: Alexander Berntsen <bernalex@gentoo.org>
---
Add exception in case eselect is not found. Fix output a tiny bit.

 pym/_emerge/actions.py     | 17 +++++++++++++++--
 pym/_emerge/post_emerge.py |  5 ++++-
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index b935139..a050b79 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -4058,8 +4058,21 @@ def run_action(emerge_config):
 
 		# GLEP 42 says to display news *after* an emerge --pretend
 		if "--pretend" not in emerge_config.opts:
-			display_news_notification(
-				emerge_config.target_config, emerge_config.opts)
+			uq = UserQuery(emerge_config.opts)
+			if display_news_notification(emerge_config.target_config,
+								emerge_config.opts) \
+				and "--ask" in emerge_config.opts \
+				and uq.query("Would you like to read the news items while " \
+						"calculating dependencies?",
+						'--ask-enter-invalid' in emerge_config.opts) == "Yes":
+				try:
+					subprocess.call(['eselect', 'news', 'read'])
+				# If eselect is not installed, Python <3.3 will throw an
+				# OSError. 3.4 will throw a FileNotFoundError, which is an
+				# subclass of OSError.
+				except OSError:
+					writemsg("Please install eselect to use this feature.\n",
+							noiselevel=-1)
 		retval = action_build(emerge_config.target_config.settings,
 			emerge_config.trees, emerge_config.target_config.mtimedb,
 			emerge_config.opts, emerge_config.action,
diff --git a/pym/_emerge/post_emerge.py b/pym/_emerge/post_emerge.py
index d5f1ba5..0cb533c 100644
--- a/pym/_emerge/post_emerge.py
+++ b/pym/_emerge/post_emerge.py
@@ -37,11 +37,14 @@ def clean_logs(settings):
 
 def display_news_notification(root_config, myopts):
 	if "news" not in root_config.settings.features:
-		return
+		return False
 	portdb = root_config.trees["porttree"].dbapi
 	vardb = root_config.trees["vartree"].dbapi
 	news_counts = count_unread_news(portdb, vardb)
+	if all(v == 0 for v in news_counts.values()):
+		return False
 	display_news_notifications(news_counts)
+	return True
 
 def show_depclean_suggestion():
 	out = portage.output.EOutput()
-- 
1.8.5.5



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-portage-dev] [PATCHv3] Offer to read news while calcing deps (bug 517310)
  2014-08-01 20:02 [gentoo-portage-dev] [PATCH] Offer to read news while calcing deps (bug 517310) Alexander Berntsen
  2014-09-22 11:26 ` Alexander Berntsen
@ 2014-09-22 11:48 ` Alexander Berntsen
  2014-09-26 19:09   ` Brian Dolbec
  1 sibling, 1 reply; 4+ messages in thread
From: Alexander Berntsen @ 2014-09-22 11:48 UTC (permalink / raw
  To: gentoo-portage-dev

Signed-off-by: Alexander Berntsen <bernalex@gentoo.org>
---
Fix some comment snafus that Arfrever spotted.

 pym/_emerge/actions.py     | 17 +++++++++++++++--
 pym/_emerge/post_emerge.py |  5 ++++-
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index b935139..ff7512a 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -4058,8 +4058,21 @@ def run_action(emerge_config):
 
 		# GLEP 42 says to display news *after* an emerge --pretend
 		if "--pretend" not in emerge_config.opts:
-			display_news_notification(
-				emerge_config.target_config, emerge_config.opts)
+			uq = UserQuery(emerge_config.opts)
+			if display_news_notification(emerge_config.target_config,
+								emerge_config.opts) \
+				and "--ask" in emerge_config.opts \
+				and uq.query("Would you like to read the news items while " \
+						"calculating dependencies?",
+						'--ask-enter-invalid' in emerge_config.opts) == "Yes":
+				try:
+					subprocess.call(['eselect', 'news', 'read'])
+				# If eselect is not installed, Python <3.3 will throw an
+				# OSError. >=3.3 will throw a FileNotFoundError, which is a
+				# subclass of OSError.
+				except OSError:
+					writemsg("Please install eselect to use this feature.\n",
+							noiselevel=-1)
 		retval = action_build(emerge_config.target_config.settings,
 			emerge_config.trees, emerge_config.target_config.mtimedb,
 			emerge_config.opts, emerge_config.action,
diff --git a/pym/_emerge/post_emerge.py b/pym/_emerge/post_emerge.py
index d5f1ba5..0cb533c 100644
--- a/pym/_emerge/post_emerge.py
+++ b/pym/_emerge/post_emerge.py
@@ -37,11 +37,14 @@ def clean_logs(settings):
 
 def display_news_notification(root_config, myopts):
 	if "news" not in root_config.settings.features:
-		return
+		return False
 	portdb = root_config.trees["porttree"].dbapi
 	vardb = root_config.trees["vartree"].dbapi
 	news_counts = count_unread_news(portdb, vardb)
+	if all(v == 0 for v in news_counts.values()):
+		return False
 	display_news_notifications(news_counts)
+	return True
 
 def show_depclean_suggestion():
 	out = portage.output.EOutput()
-- 
1.8.5.5



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [gentoo-portage-dev] [PATCHv3] Offer to read news while calcing deps (bug 517310)
  2014-09-22 11:48 ` [gentoo-portage-dev] [PATCHv3] " Alexander Berntsen
@ 2014-09-26 19:09   ` Brian Dolbec
  0 siblings, 0 replies; 4+ messages in thread
From: Brian Dolbec @ 2014-09-26 19:09 UTC (permalink / raw
  To: gentoo-portage-dev

On Mon, 22 Sep 2014 13:48:57 +0200
Alexander Berntsen <bernalex@gentoo.org> wrote:

> Signed-off-by: Alexander Berntsen <bernalex@gentoo.org>
> ---
> Fix some comment snafus that Arfrever spotted.
> 
>  pym/_emerge/actions.py     | 17 +++++++++++++++--
>  pym/_emerge/post_emerge.py |  5 ++++-
>  2 files changed, 19 insertions(+), 3 deletions(-)
> 
> 

committed and released in 2.2.14_rc1

-- 
Brian Dolbec <dolsen>



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-26 19:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-01 20:02 [gentoo-portage-dev] [PATCH] Offer to read news while calcing deps (bug 517310) Alexander Berntsen
2014-09-22 11:26 ` Alexander Berntsen
2014-09-22 11:48 ` [gentoo-portage-dev] [PATCHv3] " Alexander Berntsen
2014-09-26 19:09   ` Brian Dolbec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox