public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/layman:master commit in: layman/, overlord/
@ 2011-02-14  6:00 Brian Dolbec
  0 siblings, 0 replies; only message in thread
From: Brian Dolbec @ 2011-02-14  6:00 UTC (permalink / raw
  To: gentoo-commits

commit:     429281392d97880cb075456d85e878dc077e7d51
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Feb  6 23:40:15 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Feb 13 03:55:47 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=42928139

use the new message class and fix the error recording and output

---
 layman/api.py                  |   43 +++++++++++++++++++--------------------
 layman/cli.py                  |    3 +-
 layman/config.py               |    5 +++-
 {overlord => layman}/output.py |    0
 4 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/layman/api.py b/layman/api.py
index 77e95d8..f3d68b6 100644
--- a/layman/api.py
+++ b/layman/api.py
@@ -19,10 +19,11 @@ import os
 from layman.config import BareConfig
 #from layman.action import Sync
 
-from layman.dbbase import UnknownOverlayException
+from layman.dbbase import UnknownOverlayException, UnknownOverlayMessage
 from layman.db import DB, RemoteDB
 #from layman.utils import path, delete_empty_directory
-from layman.debug import OUT
+#from layman.debug import OUT
+from layman.output import OUT
 
 # give them some values for now, these are from the packagekit backend
 # TODO  establish some proper errors for the api.
@@ -114,11 +115,7 @@ class LaymanAPI(object):
         for ovl in repos:
             if not self.is_installed(ovl):
                 results.append(True)
-                break
-            if not self.is_repo(ovl):
-                self._error(1, UNKNOWN_REPO_ID %ovl)
-                results.append(False)
-                break
+                continue
             try:
                 self._get_installed_db().delete(self._get_installed_db().select(ovl))
                 results.append(True)
@@ -145,11 +142,11 @@ class LaymanAPI(object):
         for ovl in repos:
             if self.is_installed(ovl):
                 results.append(True)
-                break
+                continue
             if not self.is_repo(ovl):
-                self._error(1, UNKNOWN_REPO_ID %ovl)
+                self._error(UnknownOverlayMessage(ovl))
                 results.append(False)
-                break
+                continue
             try:
                 self._get_installed_db().add(self._get_remote_db().select(ovl), quiet=True)
                 results.append(True)
@@ -199,12 +196,13 @@ class LaymanAPI(object):
 
         for ovl in repos:
             if not self.is_repo(ovl):
-                self._error(1, UNKNOWN_REPO_ID %ovl)
+                self._error(UnknownOverlayMessage(ovl))
                 result[ovl] = ('', False, False)
+                continue
             try:
                 overlay = db.select(ovl)
             except UnknownOverlayException, error:
-                self._error(2, "Error: %s" %str(error))
+                self._error(error)
                 result[ovl] = ('', False, False)
             else:
                 result[ovl] = {
@@ -247,20 +245,21 @@ class LaymanAPI(object):
 
         for ovl in repos:
             if not self.is_repo(ovl):
-                self._error(1, UNKNOWN_REPO_ID % ovl)
+                self._error(UnknownOverlayMessage(ovl))
                 result[ovl] = ('', False, False)
+                continue
             try:
                 overlay = db.select(ovl)
                 #print "overlay = ", ovl
-                #print overlay
+                #print "!!!", overlay
             except UnknownOverlayException, error:
                 #print "ERRORS", str(error)
-                self._error(2, "Error: %s" %str(error))
+                self._error(error)
                 result[ovl] = ('', False, False)
             else:
                 # Is the overlay supported?
                 if verbose:
-                    info = overlay.__str__()
+                    info = overlay.get_infostr()
                 else:
                     info = overlay.short_list(width)
                 official = overlay.is_official()
@@ -271,7 +270,7 @@ class LaymanAPI(object):
 
     def get_info_list(self, local=True, verbose=False, width=0):
         """retrieves the string representation of the recorded information
-        about the repo(s) specified by ovl
+        about the repo(s)
 
         @param local: bool (defaults to True)
         @param verbose: bool(defaults to False)
@@ -303,7 +302,7 @@ class LaymanAPI(object):
             try:
                 odb = db.select(ovl)
             except UnknownOverlayException, error:
-                self._error(1,"Sync(), failed to select %s overlay.  Original error was: %s" %(ovl, str(error)))
+                self._error(UnknownOverlayException(error))
                 continue
 
             try:
@@ -376,7 +375,7 @@ class LaymanAPI(object):
         try:
             self._get_remote_db().cache()
         except Exception, error:
-            self._error(-1,'Failed to fetch overlay list!\n Original Error was: '
+            self._error('Failed to fetch overlay list!\n Original Error was: '
                     + str(error))
             return False
         self.get_available(reload=True)
@@ -417,13 +416,13 @@ class LaymanAPI(object):
         result = self.get_installed(reload=True)
 
 
-    def _error(self, num, message):
+    def _error(self, message):
         """outputs the error to the pre-determined output
         defaults to stderr.  This method may be removed, is here for now
         due to code taken from the packagekit backend.
         """
-        msg = "Error: %d," % num, message
-        self._error_messages.append(msg)
+        #msg = "Error: %d," % num, message
+        self._error_messages.append(message)
         if self.report_errors:
             print >>stderr, msg
 

diff --git a/layman/cli.py b/layman/cli.py
index dca6bb6..3277c1b 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -171,7 +171,8 @@ class Main(object):
                 try:
                     result += getattr(self, action[1])()
                 except Exception, error:
-                    self.output.error(self.api.get_errors())
+                    for _error in self.api.get_errors():
+                        self.output.error(_error)
                     result = -1  # So it cannot remain 0, i.e. success
                     break
 

diff --git a/layman/config.py b/layman/config.py
index 33951e7..e515155 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -31,7 +31,10 @@ import sys, ConfigParser
 import os
 
 from   optparse                 import OptionParser, OptionGroup
-from   layman.debug             import OUT
+
+#from   layman.debug             import OUT
+from   layman.output            import OUT
+
 from   layman.version           import VERSION
 
 #===============================================================================

diff --git a/overlord/output.py b/layman/output.py
similarity index 100%
rename from overlord/output.py
rename to layman/output.py



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-02-14  6:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-14  6:00 [gentoo-commits] proj/layman:master commit in: layman/, overlord/ Brian Dolbec

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