From 4cdaa7320b1d0624b7e6c1f08161451a7b70b373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Tue, 13 Aug 2013 17:07:58 -0300 Subject: Set the standalone flag before using it This reorders imports and delays them after the args are processed. --- src/leap/bitmask/app.py | 38 ++++++++++++++++++++++++++------------ src/leap/bitmask/gui/mainwindow.py | 2 -- 2 files changed, 26 insertions(+), 14 deletions(-) (limited to 'src/leap/bitmask') diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py index 3c418258..6ffa1d25 100644 --- a/src/leap/bitmask/app.py +++ b/src/leap/bitmask/app.py @@ -24,27 +24,15 @@ from functools import partial from PySide import QtCore, QtGui -from leap.bitmask.gui import locale_rc -from leap.bitmask.gui import twisted_main -from leap.bitmask.gui.mainwindow import MainWindow -from leap.bitmask.platform_init import IS_MAC -from leap.bitmask.platform_init.locks import we_are_the_one_and_only -#from leap.bitmask.services.tx import leap_services -from leap.bitmask.util import __version__ as VERSION from leap.bitmask.util import leap_argparse from leap.bitmask.util.leap_log_handler import LeapLogHandler from leap.bitmask.util.streamtologger import StreamToLogger -from leap.bitmask.util.requirement_checker import check_requirements from leap.common.events import server as event_server - import codecs codecs.register(lambda name: codecs.lookup('utf-8') if name == 'cp65001' else None) -# pylint: avoid unused import -assert(locale_rc) - def sigint_handler(*args, **kwargs): """ @@ -144,6 +132,29 @@ def main(): logfile = opts.log_file openvpn_verb = opts.openvpn_verb + ############################################################# + # Given how paths and bundling works, we need to delay the imports + # of certain parts that depend on this path settings. + # So first we set all the places where standalone might be queried. + from leap.bitmask.config.providerconfig import ProviderConfig + from leap.common.config.baseconfig import BaseConfig + from leap.bitmask.services.eip.eipconfig import EIPConfig + BaseConfig.standalone = standalone + ProviderConfig.standalone = standalone + EIPConfig.standalone = standalone + + # And then we import all the other stuff + from leap.bitmask.gui import locale_rc + from leap.bitmask.gui import twisted_main + from leap.bitmask.gui.mainwindow import MainWindow + from leap.bitmask.platform_init import IS_MAC + from leap.bitmask.platform_init.locks import we_are_the_one_and_only + from leap.bitmask.util import __version__ as VERSION + from leap.bitmask.util.requirement_checker import check_requirements + + # pylint: avoid unused import + assert(locale_rc) + logger = add_logger_handlers(debug, logfile) replace_stdout_stderr_with_logging(logger) @@ -162,6 +173,9 @@ def main(): logger.info('Starting app') + ProviderConfig.standalone = standalone + EIPConfig.standalone = standalone + # We force the style if on KDE so that it doesn't load all the kde # libs, which causes a compatibility issue in some systems. # For more info, see issue #3194 diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index b624988f..96cb1bfe 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -169,8 +169,6 @@ class MainWindow(QtGui.QMainWindow): # This is loaded only once, there's a bug when doing that more # than once - ProviderConfig.standalone = standalone - EIPConfig.standalone = standalone self._standalone = standalone self._provider_config = ProviderConfig() # Used for automatic start of EIP -- cgit v1.2.3