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) _at_@ -1,3 +1,5 @@ +import mb.mberr + class Directory: def __init__(self, name): self.name = name _at_@ -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) _at_@ -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.orgReceived on Tue Mar 03 2009 - 20:17:51 GMT
This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT