storage:http: adjust HTTPError message in get_post_url.
authorW. Trevor King <wking@tremily.us>
Fri, 24 Aug 2012 11:24:31 +0000 (07:24 -0400)
committerW. Trevor King <wking@tremily.us>
Fri, 24 Aug 2012 11:27:14 +0000 (07:27 -0400)
We'll usually get this message if we fail to reach the server, but we
can also get it if the server is so broken that it dies without
returning a valid HTTP response.

libbe/storage/http.py

index cfed7b71282926caac7f9dbef33e665d41929bff..20dade49a2fc0ba2dad75b0197ffe7852cf99f4b 100644 (file)
@@ -112,8 +112,8 @@ def get_post_url(url, get=True, data_dict=None, headers=[], agent=None):
         response = urllib2.urlopen(req)
     except urllib2.HTTPError, e:
         if hasattr(e, 'reason'):
-            msg = 'We failed to reach a server.\nURL: %s\nReason: %s' \
-                (url, e.reason)
+            msg = ('We failed to connect to the server.\nURL: {}\n'
+                   'Reason: {}').format(url, e.reason)
         elif hasattr(e, 'code'):
             msg = "The server couldn't fulfill the request.\nURL: %s\nError code: %s" \
                 % (url, e.code)