mirror of https://github.com/huashengdun/webssh
Change self to cls in class methods
parent
fb5bf28deb
commit
f78588bcc1
|
@ -55,7 +55,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
|
||||||
return data.decode('utf-8')
|
return data.decode('utf-8')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_specific_pkey(self, pkeycls, privatekey, password):
|
def get_specific_pkey(cls, pkeycls, privatekey, password):
|
||||||
logging.info('Trying {}'.format(pkeycls.__name__))
|
logging.info('Trying {}'.format(pkeycls.__name__))
|
||||||
try:
|
try:
|
||||||
pkey = pkeycls.from_private_key(io.StringIO(privatekey),
|
pkey = pkeycls.from_private_key(io.StringIO(privatekey),
|
||||||
|
@ -68,13 +68,13 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
|
||||||
return pkey
|
return pkey
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_pkey_obj(self, privatekey, password):
|
def get_pkey_obj(cls, privatekey, password):
|
||||||
password = password.encode('utf-8') if password else None
|
password = password.encode('utf-8') if password else None
|
||||||
|
|
||||||
pkey = self.get_specific_pkey(paramiko.RSAKey, privatekey, password)\
|
pkey = cls.get_specific_pkey(paramiko.RSAKey, privatekey, password)\
|
||||||
or self.get_specific_pkey(paramiko.DSSKey, privatekey, password)\
|
or cls.get_specific_pkey(paramiko.DSSKey, privatekey, password)\
|
||||||
or self.get_specific_pkey(paramiko.ECDSAKey, privatekey, password)\
|
or cls.get_specific_pkey(paramiko.ECDSAKey, privatekey, password)\
|
||||||
or self.get_specific_pkey(paramiko.Ed25519Key, privatekey,
|
or cls.get_specific_pkey(paramiko.Ed25519Key, privatekey,
|
||||||
password)
|
password)
|
||||||
if not pkey:
|
if not pkey:
|
||||||
raise ValueError('Not a valid private key file or '
|
raise ValueError('Not a valid private key file or '
|
||||||
|
|
Loading…
Reference in New Issue