From fdbafa4929cb9969e8f2ea3b256eb4bd9f99a7a7 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 6 Jun 2014 12:10:08 -0300 Subject: Move quit callback to mainwindow. --- src/leap/bitmask/app.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/leap/bitmask/app.py') diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py index e965604a..1ed58701 100644 --- a/src/leap/bitmask/app.py +++ b/src/leap/bitmask/app.py @@ -170,7 +170,6 @@ def main(): # And then we import all the other stuff # I think it's safe to import at the top by now -- kali 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 @@ -231,10 +230,8 @@ def main(): #timer.timeout.connect(lambda: None) # XXX --------------------------------------------------------- - window = MainWindow( - lambda: twisted_main.quit(app), - bypass_checks=bypass_checks, - start_hidden=start_hidden) + window = MainWindow(bypass_checks=bypass_checks, + start_hidden=start_hidden) sigint_window = partial(sigint_handler, window, logger=logger) signal.signal(signal.SIGINT, sigint_window) -- cgit v1.2.3 From 89d01ea3a353e3a7d6f973847d02e16147781448 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 6 Jun 2014 12:20:33 -0300 Subject: Remove code already used in mainwindow. --- src/leap/bitmask/app.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/leap/bitmask/app.py') diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py index 1ed58701..1d2ecfc7 100644 --- a/src/leap/bitmask/app.py +++ b/src/leap/bitmask/app.py @@ -171,7 +171,6 @@ def main(): # I think it's safe to import at the top by now -- kali from leap.bitmask.gui import locale_rc 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.requirement_checker import check_requirements @@ -239,9 +238,6 @@ def main(): # callable used in addSystemEventTrigger to handle SIGTERM sigterm_window = partial(sigterm_handler, window, logger=logger) - if IS_MAC: - window.raise_() - # This was a good idea, but for this to work as intended we # should centralize the start of all services in there. #tx_app = leap_services() -- cgit v1.2.3 From f2c94006877fef883cd34e9d6b3f3c329aa39ed1 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 6 Jun 2014 12:21:23 -0300 Subject: Remove unused code. --- src/leap/bitmask/app.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/leap/bitmask/app.py') diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py index 1d2ecfc7..65978f72 100644 --- a/src/leap/bitmask/app.py +++ b/src/leap/bitmask/app.py @@ -238,11 +238,6 @@ def main(): # callable used in addSystemEventTrigger to handle SIGTERM sigterm_window = partial(sigterm_handler, window, logger=logger) - # This was a good idea, but for this to work as intended we - # should centralize the start of all services in there. - #tx_app = leap_services() - #assert(tx_app) - l = LoopingCall(QtCore.QCoreApplication.processEvents, 0, 10) l.start(0.01) -- cgit v1.2.3 From d2eb54c4789afa780d72e80d89eb0c738ed61a33 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 6 Jun 2014 12:41:24 -0300 Subject: Move imports to the top. --- src/leap/bitmask/app.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/leap/bitmask/app.py') diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py index 65978f72..8d4a12ba 100644 --- a/src/leap/bitmask/app.py +++ b/src/leap/bitmask/app.py @@ -48,9 +48,14 @@ from functools import partial from PySide import QtCore, QtGui from leap.bitmask import __version__ as VERSION -from leap.bitmask.util import leap_argparse +from leap.bitmask.gui import locale_rc # noqa - silence pylint +from leap.bitmask.gui.mainwindow import MainWindow from leap.bitmask.logs.utils import get_logger +from leap.bitmask.platform_init.locks import we_are_the_one_and_only from leap.bitmask.services.mail import plumber +from leap.bitmask.util import leap_argparse +from leap.bitmask.util.requirement_checker import check_requirements + from leap.common.events import server as event_server from leap.mail import __version__ as MAIL_VERSION @@ -167,16 +172,6 @@ def main(): nice = os.nice(int(PLAY_NICE)) logger.info("Setting NICE: %s" % nice) - # And then we import all the other stuff - # I think it's safe to import at the top by now -- kali - from leap.bitmask.gui import locale_rc - from leap.bitmask.gui.mainwindow import MainWindow - from leap.bitmask.platform_init.locks import we_are_the_one_and_only - from leap.bitmask.util.requirement_checker import check_requirements - - # pylint: avoid unused import - assert(locale_rc) - # TODO move to a different module: commands? if not we_are_the_one_and_only(): # Bitmask is already running -- cgit v1.2.3 From acac7e91124d59e6456d74118d144edb52675f95 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 6 Jun 2014 12:49:31 -0300 Subject: Remove unused code and move imports to the top. --- src/leap/bitmask/app.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/leap/bitmask/app.py') diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py index 8d4a12ba..e25ab753 100644 --- a/src/leap/bitmask/app.py +++ b/src/leap/bitmask/app.py @@ -48,6 +48,7 @@ from functools import partial from PySide import QtCore, QtGui from leap.bitmask import __version__ as VERSION +from leap.bitmask.config import flags from leap.bitmask.gui import locale_rc # noqa - silence pylint from leap.bitmask.gui.mainwindow import MainWindow from leap.bitmask.logs.utils import get_logger @@ -139,12 +140,6 @@ def main(): logger = get_logger(debug, logfile, replace_stdout) - ############################################################# - # 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 import flags - from leap.common.config.baseconfig import BaseConfig flags.STANDALONE = standalone flags.OFFLINE = offline flags.MAIL_LOGFILE = mail_logfile @@ -155,8 +150,6 @@ def main(): flags.CA_CERT_FILE = opts.ca_cert_file - BaseConfig.standalone = standalone - # ok, we got logging in place, we can satisfy mail plumbing requests # and show logs there. it normally will exit there if we got that path. do_mail_plumbing(opts) -- cgit v1.2.3 From 59fb00b65c1fa2813b0751865bd7789e2fbf54f8 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 6 Jun 2014 13:00:50 -0300 Subject: Remove unused variables and reorder arg parsing. --- src/leap/bitmask/app.py | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'src/leap/bitmask/app.py') diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py index e25ab753..1f20d0d4 100644 --- a/src/leap/bitmask/app.py +++ b/src/leap/bitmask/app.py @@ -120,29 +120,16 @@ def main(): """ Starts the main event loop and launches the main window. """ - # TODO move boilerplate outa here! + # Parse arguments and store them _, opts = leap_argparse.init_leapc_args() do_display_version(opts) - standalone = opts.standalone - offline = opts.offline - bypass_checks = getattr(opts, 'danger', False) - debug = opts.debug - logfile = opts.log_file - mail_logfile = opts.mail_log_file + bypass_checks = opts.danger start_hidden = opts.start_hidden - replace_stdout = True - if opts.repair or opts.import_maildir: - # We don't want too much clutter on the comand mode - # this could be more generic with a Command class. - replace_stdout = False - - logger = get_logger(debug, logfile, replace_stdout) - - flags.STANDALONE = standalone - flags.OFFLINE = offline - flags.MAIL_LOGFILE = mail_logfile + flags.STANDALONE = opts.standalone + flags.OFFLINE = opts.offline + flags.MAIL_LOGFILE = opts.mail_log_file flags.APP_VERSION_CHECK = opts.app_version_check flags.API_VERSION_CHECK = opts.api_version_check flags.OPENVPN_VERBOSITY = opts.openvpn_verb @@ -150,6 +137,14 @@ def main(): flags.CA_CERT_FILE = opts.ca_cert_file + replace_stdout = True + if opts.repair or opts.import_maildir: + # We don't want too much clutter on the comand mode + # this could be more generic with a Command class. + replace_stdout = False + + logger = get_logger(opts.debug, opts.log_file, replace_stdout) + # ok, we got logging in place, we can satisfy mail plumbing requests # and show logs there. it normally will exit there if we got that path. do_mail_plumbing(opts) -- cgit v1.2.3 From e02b98fbdb868111d20b7447a15f60ca494d27dc Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 6 Jun 2014 13:02:03 -0300 Subject: Use a more significative name for logger helper. --- src/leap/bitmask/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/leap/bitmask/app.py') diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py index 1f20d0d4..374c91d2 100644 --- a/src/leap/bitmask/app.py +++ b/src/leap/bitmask/app.py @@ -51,7 +51,7 @@ from leap.bitmask import __version__ as VERSION from leap.bitmask.config import flags from leap.bitmask.gui import locale_rc # noqa - silence pylint from leap.bitmask.gui.mainwindow import MainWindow -from leap.bitmask.logs.utils import get_logger +from leap.bitmask.logs.utils import create_logger from leap.bitmask.platform_init.locks import we_are_the_one_and_only from leap.bitmask.services.mail import plumber from leap.bitmask.util import leap_argparse @@ -143,7 +143,7 @@ def main(): # this could be more generic with a Command class. replace_stdout = False - logger = get_logger(opts.debug, opts.log_file, replace_stdout) + logger = create_logger(opts.debug, opts.log_file, replace_stdout) # ok, we got logging in place, we can satisfy mail plumbing requests # and show logs there. it normally will exit there if we got that path. -- cgit v1.2.3 From 771d6eecb83dded2301983f2fc1025b4bc1ea45a Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Mon, 9 Jun 2014 12:41:58 -0300 Subject: Use a better naming for argparse helper. --- src/leap/bitmask/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/leap/bitmask/app.py') diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py index 374c91d2..6a7d6ff1 100644 --- a/src/leap/bitmask/app.py +++ b/src/leap/bitmask/app.py @@ -121,7 +121,7 @@ def main(): Starts the main event loop and launches the main window. """ # Parse arguments and store them - _, opts = leap_argparse.init_leapc_args() + opts = leap_argparse.get_options() do_display_version(opts) bypass_checks = opts.danger -- cgit v1.2.3