未验证 提交 cfac2433 编写于 作者: 😸 😸

gpg_keyring_args: return a list instead of a string

Both callers were using `split()` to get a list already.  So we should
just return a list isntead of `join`ing and `split`ting.

Also make the way the gpg command is constructed in the callers look a
bit nicer.
上级 aed272e2
......@@ -76,7 +76,7 @@ def main():
cmd = ["gpg", "--with-colons", "--no-secmem-warning",
"--no-auto-check-trustdb", "--with-fingerprint",
"--no-default-keyring"]
cmd.extend(utils.gpg_keyring_args(keyrings).split())
cmd.extend(utils.gpg_keyring_args(keyrings))
cmd.extend(["--list-key", "--", Cnf["Add-User::Options::Key"]])
output = subprocess.check_output(cmd).rstrip()
m = re_gpg_fingerprint_colon.search(output)
......
......@@ -722,7 +722,7 @@ def gpg_keyring_args(keyrings=None):
if not keyrings:
keyrings = get_active_keyring_paths()
return " ".join(["--keyring %s" % x for x in keyrings])
return ["--keyring={}".format(path) for path in keyrings]
################################################################################
......@@ -735,9 +735,10 @@ def gpg_get_key_addresses(fingerprint):
addresses = list()
try:
with open(os.devnull, "wb") as devnull:
output = daklib.daksubprocess.check_output(
["gpg", "--no-default-keyring"] + gpg_keyring_args().split()
+ ["--with-colons", "--list-keys", fingerprint], stderr=devnull)
cmd = ["gpg", "--no-default-keyring"]
cmd.extend(gpg_keyring_args())
cmd.extend(["--with-colons", "--list-keys", "--", fingerprint])
output = daklib.daksubprocess.check_output(cmd, stderr=devnull)
except subprocess.CalledProcessError:
pass
else:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册