[flashproxy/master] unify common parts of build_register_command
commit 0361a009f6c13dd125c8ad3267d0c9fc6074b298 Author: Ximin Luo <infinity0@torproject.org> Date: Sun Jul 6 21:53:46 2014 +0100 unify common parts of build_register_command --- flashproxy-client | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/flashproxy-client b/flashproxy-client index b69d1bf..05d2fdb 100755 --- a/flashproxy-client +++ b/flashproxy-client @@ -898,34 +898,31 @@ def build_register_command(method): # Maybe the script was read from stdin; in any case don't guess at the directory. raise ValueError("Can't find executable directory for registration helpers") - # "common" is options shared by every registration helper. - common = [] + if method not in ("http", "appspot", "email"): + raise ValueError("Unknown registration method \"%s\"" % method) + + args = [] + + # facilitator selection + if method == "http": + if options.facilitator_url is not None: + args += ["-f", options.facilitator_url] + else: + if options.facilitator_pubkey_filename is not None: + args += ["--facilitator-pubkey", options.facilitator_pubkey_filename] + + # options shared by every registration helper. if options.address_family == socket.AF_INET: - common += ["-4"] + args += ["-4"] elif options.address_family == socket.AF_INET6: - common += ["-6"] + args += ["-6"] if options.transport is not None: - common += ["--transport", options.transport] + args += ["--transport", options.transport] if not options.safe_logging: - common += ["--unsafe-logging"] + args += ["--unsafe-logging"] - if method == "appspot": - command = [os.path.join(script_dir, "flashproxy-reg-appspot")] + common - if options.facilitator_pubkey_filename is not None: - command += ["--facilitator-pubkey", options.facilitator_pubkey_filename] - return command - elif method == "email": - command = [os.path.join(script_dir, "flashproxy-reg-email")] + common - if options.facilitator_pubkey_filename is not None: - command += ["--facilitator-pubkey", options.facilitator_pubkey_filename] - return command - elif method == "http": - command = [os.path.join(script_dir, "flashproxy-reg-http")] + common - if options.facilitator_url is not None: - command += ["-f", options.facilitator_url] - return command - else: - raise ValueError("Unknown registration method \"%s\"" % method) + prog = os.path.join(script_dir, "flashproxy-reg-%s" % method) + return [prog] + args def pt_escape(s): result = []
participants (1)
-
infinity0@torproject.org