本文整理汇总了Python中mailpile.crypto.gpgi.GnuPG.recv_key方法的典型用法代码示例。如果您正苦于以下问题:Python GnuPG.recv_key方法的具体用法?Python GnuPG.recv_key怎么用?Python GnuPG.recv_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mailpile.crypto.gpgi.GnuPG
的用法示例。
在下文中一共展示了GnuPG.recv_key方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: command
# 需要导入模块: from mailpile.crypto.gpgi import GnuPG [as 别名]
# 或者: from mailpile.crypto.gpgi.GnuPG import recv_key [as 别名]
def command(self):
keyid = self.data.get("keyid", self.args)
g = GnuPG()
res = []
for key in keyid:
res.append(g.recv_key(key))
return res
示例2: _getkey
# 需要导入模块: from mailpile.crypto.gpgi import GnuPG [as 别名]
# 或者: from mailpile.crypto.gpgi.GnuPG import recv_key [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")
示例3: _getkey
# 需要导入模块: from mailpile.crypto.gpgi import GnuPG [as 别名]
# 或者: from mailpile.crypto.gpgi.GnuPG import recv_key [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")
示例4: command
# 需要导入模块: from mailpile.crypto.gpgi import GnuPG [as 别名]
# 或者: from mailpile.crypto.gpgi.GnuPG import recv_key [as 别名]
def command(self):
keyid = self.data.get("keyid", self.args[0])
g = GnuPG()
return g.recv_key(keyid)