本文整理匯總了Python中paramiko.client.WarningPolicy方法的典型用法代碼示例。如果您正苦於以下問題:Python client.WarningPolicy方法的具體用法?Python client.WarningPolicy怎麽用?Python client.WarningPolicy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類paramiko.client
的用法示例。
在下文中一共展示了client.WarningPolicy方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ssh_signup
# 需要導入模塊: from paramiko import client [as 別名]
# 或者: from paramiko.client import WarningPolicy [as 別名]
def ssh_signup(user):
# TODO: configure nodes used for authentication
auth_node = next(iter(SSH.AVAILABLE_NODES))
ssh_key = TensorHiveManager().dedicated_ssh_key
test_client = SSHClient()
test_client.load_system_host_keys()
test_client.set_missing_host_key_policy(WarningPolicy())
try:
test_client.connect(auth_node, username=user['username'], pkey=ssh_key)
except AuthenticationException:
return {'msg': G['unpriviliged']}, 403
except (BadHostKeyException, SSHException, socket.error) as e:
return 'An error ocurred while authenticating: {}'.format(e), 500
finally:
test_client.close()
return do_create(user)
示例2: test_get_policy_dictionary
# 需要導入模塊: from paramiko import client [as 別名]
# 或者: from paramiko.client import WarningPolicy [as 別名]
def test_get_policy_dictionary(self):
classes = [AutoAddPolicy, RejectPolicy, WarningPolicy]
dic = get_policy_dictionary()
for cls in classes:
val = dic[cls.__name__.lower()]
self.assertIs(cls, val)
示例3: test_get_policy_class
# 需要導入模塊: from paramiko import client [as 別名]
# 或者: from paramiko.client import WarningPolicy [as 別名]
def test_get_policy_class(self):
keys = ['autoadd', 'reject', 'warning']
vals = [AutoAddPolicy, RejectPolicy, WarningPolicy]
for key, val in zip(keys, vals):
cls = get_policy_class(key)
self.assertIs(cls, val)
key = 'non-exists'
with self.assertRaises(ValueError):
get_policy_class(key)