Commit 02c56e7a by Sheng

Generated friendly error message for some exception types

parent c9913a41
import io import io
import logging import logging
import os.path import os.path
import socket
import traceback import traceback
import uuid import uuid
import weakref import weakref
...@@ -186,7 +187,12 @@ class IndexHandler(tornado.web.RequestHandler): ...@@ -186,7 +187,12 @@ class IndexHandler(tornado.web.RequestHandler):
args = self.get_args() args = self.get_args()
dst_addr = '{}:{}'.format(*args[:2]) dst_addr = '{}:{}'.format(*args[:2])
logging.info('Connecting to {}'.format(dst_addr)) logging.info('Connecting to {}'.format(dst_addr))
ssh.connect(*args) try:
ssh.connect(*args, timeout=6)
except socket.error:
raise ValueError('Unable to connect to {}'.format(dst_addr))
except paramiko.BadAuthenticationType:
raise ValueError('Authentication failed.')
chan = ssh.invoke_shell(term='xterm') chan = ssh.invoke_shell(term='xterm')
chan.setblocking(0) chan.setblocking(0)
worker = Worker(ssh, chan, dst_addr) worker = Worker(ssh, chan, dst_addr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment