commit 130fe4ff0ff52192c390b5157fd45eb75579d1d2 Author: Alexandre Allaire alexandre.allaire@mail.mcgill.ca Date: Fri Feb 8 11:10:55 2013 -0500
Do not fail if facilitator doesn't provide a polling interval.
Do not raise an exception in get_reg() if the facilitator doesn't provide a polling interval. --- facilitator/fac.py | 27 ++++++++++++--------------- 1 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/facilitator/fac.py b/facilitator/fac.py index 7d55221..357009c 100644 --- a/facilitator/fac.py +++ b/facilitator/fac.py @@ -217,18 +217,17 @@ def get_reg(facilitator_addr, proxy_addr): command, params = transact(f, "GET", ("FROM", format_addr(proxy_addr))) finally: f.close() + response = {} check_back_in = param_first("CHECK-BACK-IN", params) - if not check_back_in: - raise ValueError("Facilitator did not return polling interval.") - try: - float(check_back_in) - except ValueError: - raise ValueError("Facilitator returned non-numeric polling interval.") + if check_back_in is not None: + try: + float(check_back_in) + except ValueError: + raise ValueError("Facilitator returned non-numeric polling interval.") + response["check-back-in"] = check_back_in if command == "NONE": - return { - "client": "", - "check-back-in": check_back_in, - } + response["client"] = "" + return response elif command == "OK": client_spec = param_first("CLIENT", params) relay_spec = param_first("RELAY", params) @@ -239,10 +238,8 @@ def get_reg(facilitator_addr, proxy_addr): # Check the syntax returned by the facilitator. client = parse_addr_spec(client_spec) relay = parse_addr_spec(relay_spec) - return { - "client": format_addr(client), - "relay": format_addr(relay), - "check-back-in": check_back_in, - } + response["client"] = format_addr(client) + response["relay"] = format_addr(relay) + return response else: raise ValueError("Facilitator response was not "OK"")