mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-11 11:25:34 +00:00
We can't initialize Sentry during module initialization because our `initialize_sentry` logs some status info. Setting the logging level later on is then a no-op, breaking verbose and very-verbose logging. This change fixes this by putting Sentry initialization into a separate method that gets called after we set the log level. Also refactor some common code into methods that appear in all our executables.
50 lines
2.2 KiB
Python
Executable file
50 lines
2.2 KiB
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import argparse
|
|
import logging
|
|
|
|
from keyman_config import __versionwithtag__, __pkgversion__, add_standard_arguments, initialize_logging, initialize_sentry
|
|
from keyman_config.handle_install import download_and_install_package
|
|
from keyman_config.ibus_util import verify_ibus_daemon
|
|
from keyman_config.view_installed import ViewInstalledWindow
|
|
|
|
|
|
if __name__ == '__main__':
|
|
parser = argparse.ArgumentParser(description='km-config shows the currently installed ' +
|
|
'Keyman keyboard packages and allows you to view ' +
|
|
'information about them. It enables you to download new ' +
|
|
'keyboard packages from the website or install from ' +
|
|
'local files.')
|
|
parser.add_argument('-i', '--install', action='store', help='download and/or install .kmp ' +
|
|
'package. INSTALL can either be a downloaded .kmp file, a file:// URL ' +
|
|
'pointing to a .kmp file, or a keyman:// URL, possibly with a ' +
|
|
'bcp47=<language> specified (e.g. keyman://download/keyboard/' +
|
|
'sil_el_ethiopian_latin?bcp47=ssy-latn).')
|
|
parser.add_argument('url', nargs='?', default='', metavar='INSTALL',
|
|
help='download and/or install .kmp ' +
|
|
'package. INSTALL can either be a downloaded .kmp file, a file:// URL ' +
|
|
'pointing to a .kmp file, or a keyman:// URL, possibly with a ' +
|
|
'bcp47=<language> specified (e.g. keyman://download/keyboard/' +
|
|
'sil_el_ethiopian_latin?bcp47=ssy-latn).')
|
|
add_standard_arguments(parser)
|
|
|
|
args = parser.parse_args()
|
|
|
|
initialize_logging(args)
|
|
initialize_sentry()
|
|
|
|
logging.info('Keyman version %s %s', __versionwithtag__, __pkgversion__)
|
|
|
|
verify_ibus_daemon(False)
|
|
|
|
if args.install:
|
|
download_and_install_package(args.install)
|
|
elif args.url:
|
|
download_and_install_package(args.url)
|
|
else:
|
|
w = ViewInstalledWindow()
|
|
try:
|
|
w.run()
|
|
except KeyboardInterrupt:
|
|
logging.debug('User cancelled the app')
|
|
w.destroy()
|