本文整理汇总了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)