[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Give an error when we get an http error from the dirser...



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv16691/lib/mixminion

Modified Files:
	ClientMain.py 
Log Message:
Give an error when we get an http error from the dirserver

Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- ClientMain.py	13 Feb 2003 12:02:39 -0000	1.57
+++ ClientMain.py	13 Feb 2003 18:45:07 -0000	1.58
@@ -61,6 +61,12 @@
 
 #----------------------------------------------------------------------
 
+class MyURLOpener(urllib.FancyURLopener):
+    def http_error_default(self, url, fp, errcode, errmsg, headers):
+        message = fp.read()
+        fp.close()
+        raise UIError("Error connecting to %s: %s %s\n(Server said:\n%s)" % (url, errcode, errmsg, message))
+    
 class ClientDirectory:
     """A ClientDirectory manages a list of server descriptors, either
        imported from the command line or from a directory."""
@@ -137,7 +143,7 @@
         url = MIXMINION_DIRECTORY_URL
         LOG.info("Downloading directory from %s", url)
         try:
-            infile = urllib.FancyURLopener().open(url)
+            infile = MyURLOpener().open(url)
         except IOError, e:
             raise UIError(
                 ("Couldn't connect to directory server: %s.\n"
@@ -1182,6 +1188,7 @@
     #             the latest midnight preceeding the time when this
     #                 packet was inserted into the pool.
     #           )
+    # XXXX004 change this to be OO; add nicknames.
     
     # XXXX004 write unit tests