未验证 提交 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(): ...@@ -76,7 +76,7 @@ def main():
cmd = ["gpg", "--with-colons", "--no-secmem-warning", cmd = ["gpg", "--with-colons", "--no-secmem-warning",
"--no-auto-check-trustdb", "--with-fingerprint", "--no-auto-check-trustdb", "--with-fingerprint",
"--no-default-keyring"] "--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"]]) cmd.extend(["--list-key", "--", Cnf["Add-User::Options::Key"]])
output = subprocess.check_output(cmd).rstrip() output = subprocess.check_output(cmd).rstrip()
m = re_gpg_fingerprint_colon.search(output) m = re_gpg_fingerprint_colon.search(output)
......
...@@ -722,7 +722,7 @@ def gpg_keyring_args(keyrings=None): ...@@ -722,7 +722,7 @@ def gpg_keyring_args(keyrings=None):
if not keyrings: if not keyrings:
keyrings = get_active_keyring_paths() 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): ...@@ -735,9 +735,10 @@ def gpg_get_key_addresses(fingerprint):
addresses = list() addresses = list()
try: try:
with open(os.devnull, "wb") as devnull: with open(os.devnull, "wb") as devnull:
output = daklib.daksubprocess.check_output( cmd = ["gpg", "--no-default-keyring"]
["gpg", "--no-default-keyring"] + gpg_keyring_args().split() cmd.extend(gpg_keyring_args())
+ ["--with-colons", "--list-keys", fingerprint], stderr=devnull) cmd.extend(["--with-colons", "--list-keys", "--", fingerprint])
output = daklib.daksubprocess.check_output(cmd, stderr=devnull)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
pass pass
else: else:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册