From 98ecb0421d8f5cc2f1420ad39c514315fd048118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Mon, 20 Jan 2014 13:52:30 -0300 Subject: Do not try/except sections in the config, explicitly check for their existence This avoids adding useless tracebacks to the real exceptions caught by Twisted. Possible tx bug here. --- changes/bug_dont_raise_nosectionerror | 2 ++ src/launcher.py | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 changes/bug_dont_raise_nosectionerror diff --git a/changes/bug_dont_raise_nosectionerror b/changes/bug_dont_raise_nosectionerror new file mode 100644 index 0000000..fbc2306 --- /dev/null +++ b/changes/bug_dont_raise_nosectionerror @@ -0,0 +1,2 @@ + o Avoid the try/except idiom when accessing configs to avoid messing + with the client traceback. Fixes #5007. \ No newline at end of file diff --git a/src/launcher.py b/src/launcher.py index b62bd23..2a43e54 100644 --- a/src/launcher.py +++ b/src/launcher.py @@ -4,21 +4,22 @@ import time import threading import ConfigParser -from leap.bitmask.app import main as leap_client +from leap.bitmask.app import main as bitmask_client from leap.common.events import server from thandy.ClientCLI import update as thandy_update bundles_per_platform = { - "Windows" : "/bundleinfo/LEAPClient-win/", - "Darwin" : "", - "Linux" : "/bundleinfo/LEAPClient/", + "Windows": "/bundleinfo/LEAPClient-win/", + "Darwin": "", + "Linux": "/bundleinfo/LEAPClient/", } GENERAL_SECTION = "General" UPDATES_KEY = "Updates" + class Thandy(threading.Thread): def run(self): while True: @@ -50,16 +51,16 @@ if __name__ == "__main__": config.read("launcher.conf") launch_thandy = False - try: + + has_config = config.has_section(GENERAL_SECTION) and \ + config.has_option(GENERAL_SECTION, UPDATES_KEY) + + if has_config: launch_thandy = config.getboolean(GENERAL_SECTION, UPDATES_KEY) - except ConfigParser.NoSectionError as ns: - pass - except ConfigParser.NoOptionError as no: - pass if launch_thandy: thandy_thread = Thandy() thandy_thread.daemon = True thandy_thread.start() - leap_client() + bitmask_client() -- cgit v1.2.3