aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'overlord')
-rw-r--r--overlord/api.py43
-rw-r--r--overlord/cli.py3
2 files changed, 23 insertions, 23 deletions
diff --git a/overlord/api.py b/overlord/api.py
index 0fe9362..4aee39e 100644
--- a/overlord/api.py
+++ b/overlord/api.py
@@ -20,10 +20,11 @@ import os
from overlord.config import BareConfig
#from overlord.action import Sync
-from overlord.dbbase import UnknownOverlayException
+from overlord.dbbase import UnknownOverlayException, UnknownOverlayMessage
from overlord.db import DB, RemoteDB
#from overlord.utils import path, delete_empty_directory
-from overlord.debug import OUT
+#from overlord.debug import OUT
+from overlord.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 OverlordAPI(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 OverlordAPI(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 OverlordAPI(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 OverlordAPI(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 OverlordAPI(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 OverlordAPI(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 OverlordAPI(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 OverlordAPI(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/overlord/cli.py b/overlord/cli.py
index 501dd65..0953de1 100644
--- a/overlord/cli.py
+++ b/overlord/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