Commit c873b505 by Sheng

Renamed attribute filename to privatekey_filename

parent a576a41e
...@@ -71,7 +71,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler): ...@@ -71,7 +71,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
self.policy = policy self.policy = policy
self.host_keys_settings = host_keys_settings self.host_keys_settings = host_keys_settings
self.ssh_client = self.get_ssh_client() self.ssh_client = self.get_ssh_client()
self.filename = None self.privatekey_filename = None
self.result = dict(id=None, status=None, encoding=None) self.result = dict(id=None, status=None, encoding=None)
def write_error(self, status_code, **kwargs): def write_error(self, status_code, **kwargs):
...@@ -100,7 +100,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler): ...@@ -100,7 +100,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
name = 'privatekey' name = 'privatekey'
lst = self.request.files.get(name) # multipart form lst = self.request.files.get(name) # multipart form
if lst: if lst:
self.filename = lst[0]['filename'] self.privatekey_filename = lst[0]['filename']
data = lst[0]['body'] data = lst[0]['body']
value = self.decode_argument(data, name=name).strip() value = self.decode_argument(data, name=name).strip()
else: else:
...@@ -108,7 +108,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler): ...@@ -108,7 +108,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
if len(value) > KEY_MAX_SIZE: if len(value) > KEY_MAX_SIZE:
raise InvalidValueError( raise InvalidValueError(
'Invalid private key: {}'.format(self.filename) 'Invalid private key: {}'.format(self.privatekey_filename)
) )
return value return value
...@@ -179,8 +179,11 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler): ...@@ -179,8 +179,11 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
username = self.get_value('username') username = self.get_value('username')
password = self.get_argument('password', u'') password = self.get_argument('password', u'')
privatekey = self.get_privatekey() privatekey = self.get_privatekey()
pkey = self.get_pkey_obj(privatekey, password, self.filename) \ if privatekey:
if privatekey else None pkey = self.get_pkey_obj(privatekey, password,
self.privatekey_filename)
else:
pkey = None
args = (hostname, port, username, password, pkey) args = (hostname, port, username, password, pkey)
logging.debug(args) logging.debug(args)
return args return args
......
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