summaryrefslogtreecommitdiff
path: root/paramiko/ssh_exception.py
diff options
context:
space:
mode:
authorMarius Gedminas <marius@gedmin.as>2016-02-05 08:43:50 +0200
committerJeff Forcier <jeff@bitprophet.org>2016-04-24 13:56:51 -0700
commit0411010d55755913fa7bd5b0a9c719c8548549f4 (patch)
treebb05b68c06f26f455e8604234676c285300dd802 /paramiko/ssh_exception.py
parent858c167a6487e4a9d9cca3653b8e260f085dba02 (diff)
downloadparamiko-0411010d55755913fa7bd5b0a9c719c8548549f4.tar.gz
Improve NoValidConnectionsError formatting
Because "Unable to connect to port 22 on or X.X.X.X" looks seriously _weird_ with the blank space between "on" and "or".
Diffstat (limited to 'paramiko/ssh_exception.py')
-rw-r--r--paramiko/ssh_exception.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/paramiko/ssh_exception.py b/paramiko/ssh_exception.py
index bdf97e24..fea3146a 100644
--- a/paramiko/ssh_exception.py
+++ b/paramiko/ssh_exception.py
@@ -164,10 +164,13 @@ class NoValidConnectionsError(socket.error):
:param dict errors:
The errors dict to store, as described by class docstring.
"""
- addrs = list(errors.keys())
+ addrs = sorted(errors.keys())
body = ', '.join([x[0] for x in addrs[:-1]])
tail = addrs[-1][0]
- msg = "Unable to connect to port {0} on {1} or {2}"
+ if body:
+ msg = "Unable to connect to port {0} on {1} or {2}"
+ else:
+ msg = "Unable to connect to port {0} on {2}"
super(NoValidConnectionsError, self).__init__(
None, # stand-in for errno
msg.format(addrs[0][1], body, tail)