[gentoo-portage-dev] [PATCH] sync.py: extend the checks in _get_repos() and fail when necessary (bugs 567478, 576272, 601054)

2017-02-13 Thread Alexandru Elisei
The existence of the sync-type attribute is now being checked for all
repos, not just for the repos given as arguments to emerge --sync. A
message is returned when a repo without sync-type is found and sync
will fail.

Emerge will now fail if at least one of the repos given to emerge --sync
doesn't exist or has auto-sync disabled.

auto_sync() and all_repos() also fail when no valid repos are found, but
they return success when no auto-sync repos are defined, or no repos are
defined at all on the system.

This commit and commit f57ae38 'emerge: make emerge --sync print
messages from SyncRepos.auto_sync()' shoulg solve bugs 567478, 576282
and partly 601054.
---
 pym/portage/emaint/modules/sync/sync.py | 104 +++-
 1 file changed, 62 insertions(+), 42 deletions(-)

diff --git a/pym/portage/emaint/modules/sync/sync.py
b/pym/portage/emaint/modules/sync/sync.py
index 08a92a7..4d66411 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -89,25 +89,45 @@ class SyncRepos(object):
def auto_sync(self, **kwargs):
'''Sync auto-sync enabled repos'''
options = kwargs.get('options', None)
-   selected = self._get_repos(True)
if options:
return_messages = options.get('return-messages', False)
else:
return_messages = False
-   return self._sync(selected, return_messages,
-   emaint_opts=options)
+   success, selected, msgs = self._get_repos(True)
+   if not success:
+   if return_messages:
+   msgs.append(red(" * ") + \
+   "Errors were encountered while getting 
repos... returning")
+   return (False, msgs)
+   return (False, None)
+   if not selected:
+   if return_messages:
+   msgs.append("Nothing to sync... returning")
+   return (True, msgs)
+   return (True, None)
+   return self._sync(selected, return_messages, 
emaint_opts=options)


def all_repos(self, **kwargs):
'''Sync all repos defined in repos.conf'''
-   selected = self._get_repos(auto_sync_only=False)
options = kwargs.get('options', None)
if options:
return_messages = options.get('return-messages', False)
else:
return_messages = False
-   return self._sync(selected, return_messages,
-   emaint_opts=options)
+   success, selected, msgs = self._get_repos(auto_sync_only=False)
+   if not success:
+   if return_messages:
+   msgs.append(red(" * ") + \
+   "Errors were encountered while getting 
repos... returning")
+   return (False, msgs)
+   return (False, None)
+   if not selected:
+   if return_messages:
+   msgs.append("Nothing to sync... returning")
+   return (True, msgs)
+   return (True, None)
+   return self._sync(selected, return_messages, 
emaint_opts=options)


def repo(self, **kwargs):
@@ -120,16 +140,17 @@ class SyncRepos(object):
return_messages = False
if isinstance(repos, _basestring):
repos = repos.split()
-   available = self._get_repos(auto_sync_only=False)
+   success, available, msgs = self._get_repos(auto_sync_only=False)
+   # Ignore errors from _get_repos(), we only want to know if the 
repo
+   # exists.
selected = self._match_repos(repos, available)
if not selected:
-   msgs = [red(" * ") + "The specified repos were not 
found: %s" %
-   (bold(", ".join(repos))) + "\n   ...returning"]
+   msgs.append(red(" * ") + "The specified repos are 
invalid or missing: %s" %
+   (bold(", ".join(repos))) + "\n   ...returning")
if return_messages:
return (False, msgs)
return (False, None)
-   return self._sync(selected, return_messages,
-   emaint_opts=options)
+   return self._sync(selected, return_messages, 
emaint_opts=options)


@staticmethod
@@ -148,10 +169,11 @@ class SyncRepos(object):


def _get_repos(self, auto_sync_only=True):
+   msgs = []
+   emerge_repos = []
selected_repos = 

Re: [gentoo-portage-dev] [PATCH] emerge: make emerge --sync print messages from SyncRepos.auto_sync()

2017-02-13 Thread Zac Medico
On 02/04/2017 09:49 AM, Alexandru Elisei wrote:
> Emerge will only display messages if --quiet is not set.
> 
> The word 'emaint' has been removed from two messages to avoid confusion.
> ---
>  pym/_emerge/actions.py  | 7 +--
>  pym/portage/emaint/modules/sync/sync.py | 7 +++
>  2 files changed, 8 insertions(+), 6 deletions(-)

Looks good, thanks! Merged:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=f57ae38b978069e50c2b1bf2d41bffed23ecc11d

-- 
Thanks,
Zac