本文整理汇总了Python中gnupg.GPG.sign_file方法的典型用法代码示例。如果您正苦于以下问题:Python GPG.sign_file方法的具体用法?Python GPG.sign_file怎么用?Python GPG.sign_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnupg.GPG
的用法示例。
在下文中一共展示了GPG.sign_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sign
# 需要导入模块: from gnupg import GPG [as 别名]
# 或者: from gnupg.GPG import sign_file [as 别名]
def sign(self, dist):
self._reprepro('export %s' % dist)
gpg = GPG()
filename = os.path.join(self.path, 'dists/%s/Release' % dist)
detach_file = filename + '.gpg'
try:
os.unlink(detach_file)
except: pass
result = gpg.sign_file(file(filename, 'r'), keyid=conf('repository.signkey'), outputfile=detach_file)
示例2: sign
# 需要导入模块: from gnupg import GPG [as 别名]
# 或者: from gnupg.GPG import sign_file [as 别名]
def sign(config, s_filename):
"""sign the package"""
gpg_home = config.get('gpg_dir', '/var/lib/sachannelupdate/gnupg')
gpg_pass = config.get('gpg_passphrase')
gpg_keyid = config.get('gpg_keyid')
gpg = GPG(gnupghome=gpg_home)
try:
plaintext = open(s_filename, 'rb')
signature = gpg.sign_file(
plaintext, keyid=gpg_keyid, passphrase=gpg_pass, detach=True)
with open('%s.asc' % s_filename, 'wb') as handle:
handle.write(str(signature))
finally:
if 'plaintext' in locals():
plaintext.close()
示例3: sign_content
# 需要导入模块: from gnupg import GPG [as 别名]
# 或者: from gnupg.GPG import sign_file [as 别名]
def sign_content(path, keyring, key, passphrase, output_dir, output_ext='sig'):
""" Sign the content at specified path using provided keyring
:param path: path of the content file
:param keyring: keyring path to use
:param key: key id
:param passphrase: key passphrase
:param output_dir: directory in which to write the signed file
:param output_ext: extension of the signed file
"""
name = os.path.splitext(os.path.basename(path))[0]
gpg = GPG(gnupghome=keyring)
with open(path, 'rb') as content:
signed = gpg.sign_file(content, keyid=key, passphrase=passphrase,
binary=True, clearsign=False)
new_path = os.path.join(output_dir, name + '.' + output_ext)
with open(new_path, 'wb') as output:
output.write(signed.data)
return new_path