1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#!/usr/bin/python3
import argparse
import logging
import os
import sys
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from keyman_config import (
_, __versionwithtag__, __pkgversion__, add_standard_arguments,
are_requirements_missing, initialize_logging, initialize_sentry,
verify_dbus_running)
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()
Gtk.init(sys.argv[1:])
initialize_logging(args)
initialize_sentry()
verify_dbus_running()
if are_requirements_missing():
if args.install or args.url:
logging.error('Missing requirements. Please install python3-fonttools.')
else:
dialog = Gtk.MessageDialog(
parent=None, flags=0, message_type=Gtk.MessageType.ERROR,
buttons=Gtk.ButtonsType.OK,
text=_("Missing requirements. Please install python3-fonttools."))
dialog.run()
dialog.destroy()
sys.exit(1)
# Add these imports only after the check for missing dependencies!
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
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:
# Workaround for bug in webkit2gtk (#12587)
if not 'WEBKIT_DISABLE_DMABUF_RENDERER' in os.environ:
os.environ['WEBKIT_DISABLE_DMABUF_RENDERER'] = '1'
w = ViewInstalledWindow()
try:
w.run()
except KeyboardInterrupt:
logging.debug('User cancelled the app')
w.destroy()
|