本文整理汇总了Python中mailpile.crypto.gpgi.GnuPG.import_keys方法的典型用法代码示例。如果您正苦于以下问题:Python GnuPG.import_keys方法的具体用法?Python GnuPG.import_keys怎么用?Python GnuPG.import_keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mailpile.crypto.gpgi.GnuPG
的用法示例。
在下文中一共展示了GnuPG.import_keys方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _import_key
# 需要导入模块: from mailpile.crypto.gpgi import GnuPG [as 别名]
# 或者: from mailpile.crypto.gpgi.GnuPG import import_keys [as 别名]
def _import_key(self, result, keytype):
if keytype == "openpgp":
g = GnuPG(self.config)
res = g.import_keys(result[keytype])
if len(res["updated"]):
self._managed_keys_add(result["address"], keytype)
return res
else:
# We currently only support OpenPGP keys
return False
示例2: command
# 需要导入模块: from mailpile.crypto.gpgi import GnuPG [as 别名]
# 或者: from mailpile.crypto.gpgi.GnuPG import import_keys [as 别名]
def command(self):
key_data = ""
if len(self.args) != 0:
key_file = self.data.get("key_file", self.args[0])
with open(key_file) as file:
key_data = file.read()
if "key_data" in self.data:
key_data = self.data.get("key_data")
elif "key_file" in self.data:
pass
g = GnuPG()
return g.import_keys(key_data)
示例3: _import_key
# 需要导入模块: from mailpile.crypto.gpgi import GnuPG [as 别名]
# 或者: from mailpile.crypto.gpgi.GnuPG import import_keys [as 别名]
def _import_key(self, result, keytype):
if keytype == "openpgp":
g = GnuPG()
if self.config:
g.passphrase = self.config.gnupg_passphrase.get_reader()
res = g.import_keys(result[keytype])
if len(res["updated"]):
self._managed_keys_add(result["address"], keytype)
return res
else:
# We currently only support OpenPGP keys
return False
示例4: _getkey
# 需要导入模块: from mailpile.crypto.gpgi import GnuPG [as 别名]
# 或者: from mailpile.crypto.gpgi.GnuPG import import_keys [as 别名]
def _getkey(self, key):
if key["fingerprint"] and not key["url"]:
g = GnuPG()
res = g.recv_key(key["fingerprint"])
elif key["url"]:
r = urllib2.urlopen(key["url"])
result = r.readlines()
start = 0
end = len(result)
# Hack to deal with possible HTML results from keyservers:
for i in range(len(result)):
if result[i].startswith("-----BEGIN PGP"):
start = i
elif result[i].startswith("-----END PGP"):
end = i
result = "".join(result[start:end])
g = GnuPG()
res = g.import_keys(result)
return res
else:
raise ValueError("Need a fingerprint or a URL")
示例5: _getkey
# 需要导入模块: from mailpile.crypto.gpgi import GnuPG [as 别名]
# 或者: from mailpile.crypto.gpgi.GnuPG import import_keys [as 别名]
def _getkey(self, entry):
pkaver = None
fingerprint = None
url = None
for stmt in entry.split(";"):
key, value = stmt.split("=", 1)
if key == "v":
pkaver = value
elif key == "fpr":
fingerprint = value
elif key == "uri":
url = value
if pkaver != "pka1":
raise ValueError("We only know how to deal with pka version 1")
if fingerprint and not url:
g = GnuPG()
res = g.recv_key(fingerprint)
elif url:
r = urllib2.urlopen(url)
result = r.readlines()
start = 0
end = len(result)
# Hack to deal with possible HTML results from keyservers:
for i in range(len(result)):
if result[i].startswith("-----BEGIN PGP"):
start = i
elif result[i].startswith("-----END PGP"):
end = i
result = "".join(result[start:end])
g = GnuPG()
res = g.import_keys(result)
return res
else:
raise ValueError("Need a fingerprint or a URL")