[mirrorbrain-commits] [opensuse-svn] r6674 - trunk/tools/download-redirector-v2/mirrordoctor/mb

From: Novell Forge SVN <noreply_at_novell.com>
Date: Tue, 3 Mar 2009 13:17:25 -0700 (MST)
Author: poeml
Date: 2009-03-03 13:17:22 -0700 (Tue, 03 Mar 2009)
New Revision: 6674

Modified:
   trunk/tools/download-redirector-v2/mirrordoctor/mb/core.py
   trunk/tools/download-redirector-v2/mirrordoctor/mb/mberr.py
Log:
mb delete:
- raise a more appropriate error when the given mirror identifier doesn't exist


Modified: trunk/tools/download-redirector-v2/mirrordoctor/mb/core.py
===================================================================
--- trunk/tools/download-redirector-v2/mirrordoctor/mb/core.py	2009-03-03 17:15:39 UTC (rev 6673)
+++ trunk/tools/download-redirector-v2/mirrordoctor/mb/core.py	2009-03-03 20:17:22 UTC (rev 6674)
@@ -1,3 +1,5 @@
+import mb.mberr
+
 class Directory:
     def __init__(self, name):
         self.name = name
@@ -9,7 +11,10 @@
 
 
 def delete_mirror(conn, mirror):
-    m = conn.Server.select(conn.Server.q.identifier == mirror)[0]
+    try:
+        m = conn.Server.select(conn.Server.q.identifier == mirror)[0]
+    except IndexError:
+        raise mb.mberr.MirrorNotFoundError(mirror)
 
     query = """SELECT mirr_del_byid(%d, id) FROM filearr WHERE %s = ANY(mirrors)""" \
                    % (m.id, m.id)

Modified: trunk/tools/download-redirector-v2/mirrordoctor/mb/mberr.py
===================================================================
--- trunk/tools/download-redirector-v2/mirrordoctor/mb/mberr.py	2009-03-03 17:15:39 UTC (rev 6673)
+++ trunk/tools/download-redirector-v2/mirrordoctor/mb/mberr.py	2009-03-03 20:17:22 UTC (rev 6674)
@@ -38,6 +38,13 @@
         self.cmd = cmd
         self.msg = msg
 
+class MirrorNotFoundError(Error):
+    """Raised when a mirror wasn't found in the database"""
+
+    def __init__(self, msg):
+        Error.__init__(self, 'A mirror with identifier %r doesn\'t exist in the database' % (msg,))
+        self.msg = msg
+
 class SocketError(Error):
     """Raised for network errors"""
 

_______________________________________________
Opensuse-svn mailing list
Opensuse-svn_at_forge.novell.com
http://forge.novell.com/mailman/listinfo/opensuse-svn


_______________________________________________
mirrorbrain-commits mailing list

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on 2009-03-03Z20:17:51

This archive was generated by hypermail 2.2.0 : 2009-07-10Z19:18:12 GMT