def main(): _require('pyudev', 'python-pyudev') # handle ^C in console import signal signal.signal(signal.SIGINT, signal.SIG_DFL) args = _parse_arguments() if not args: return if args.action: # if any argument, run comandline and exit return _cli.run(args.action, args.hidraw_path) gi = _require('gi', 'python-gi') gi.require_version('Gtk', '3.0') _require('gi.repository.Gtk', 'gir1.2-gtk-3.0') try: import solaar.ui as ui import solaar.listener as listener listener.setup_scanner(ui.status_changed, ui.error_dialog) import solaar.upower as _upower if args.restart_on_wake_up: _upower.watch(listener.start_all, listener.stop_all) else: _upower.watch(listener.ping_all) # main UI event loop ui.run_loop(listener.start_all, listener.stop_all) except Exception as e: import sys sys.exit('%s: error: %s' % (NAME.lower(), e))
def main(): _require('pyudev', 'python3-pyudev') # handle ^C in console import signal signal.signal(signal.SIGINT, signal.SIG_DFL) signal.signal(signal.SIGINT, _handlesigint) args = _parse_arguments() if not args: return if args.action: # if any argument, run comandline and exit return _cli.run(args.action, args.hidraw_path) gi = _require('gi', 'python3-gi or python3-gobject') _require('gi.repository.Gtk', 'gir1.2-gtk-3.0', gi, 'Gtk', '3.0') try: import solaar.ui as ui import solaar.listener as listener listener.setup_scanner(ui.status_changed, ui.error_dialog) import solaar.upower as _upower if args.restart_on_wake_up: _upower.watch(listener.start_all, listener.stop_all) else: _upower.watch(lambda: listener.ping_all(True)) # main UI event loop ui.run_loop(listener.start_all, listener.stop_all, args.window != 'only', args.window != 'hide') except Exception: import sys from traceback import format_exc sys.exit('%s: error: %s' % (NAME.lower(), format_exc()))
def main(): _require('pyudev', 'python3-pyudev') # handle ^C in console import signal signal.signal(signal.SIGINT, signal.SIG_DFL) signal.signal(signal.SIGINT, _handlesigint) args = _parse_arguments() if not args: return if args.action: # if any argument, run comandline and exit return _cli.run(args.action, args.hidraw_path) gi = _require('gi', 'python3-gi or python3-gobject') _require('gi.repository.Gtk', 'gir1.2-gtk-3.0', gi, 'Gtk', '3.0') udev_file = '42-logitech-unify-permissions.rules' if not os.path.isfile('/etc/udev/rules.d/' + udev_file) and not os.path.isfile( '/lib/udev/rules.d/' + udev_file): print(_i18n._('ERROR: '), end='') print(_i18n._('Solaar depends on a udev file that is not present'), end='.\n') print( _i18n._( 'For more information see the Solaar installation directions\n' 'at https://pwr-solaar.github.io/Solaar/installation')) try: import solaar.ui as ui import solaar.listener as listener listener.setup_scanner(ui.status_changed, ui.error_dialog) import solaar.upower as _upower if args.restart_on_wake_up: _upower.watch(listener.start_all, listener.stop_all) else: _upower.watch(lambda: listener.ping_all(True)) # main UI event loop ui.run_loop(listener.start_all, listener.stop_all, args.window != 'only', args.window != 'hide') except Exception: import sys from traceback import format_exc sys.exit('%s: error: %s' % (NAME.lower(), format_exc()))
def main(): _require('pyudev', 'python3-pyudev') # handle ^C in console import signal signal.signal(signal.SIGINT, signal.SIG_DFL) signal.signal(signal.SIGINT, _handlesigint) args = _parse_arguments() if not args: return if args.action: # if any argument, run comandline and exit return _cli.run(args.action, args.hidraw_path) gi = _require('gi', 'python3-gi (in Ubuntu) or python3-gobject (in Fedora)') _require('gi.repository.Gtk', 'gir1.2-gtk-3.0', gi, 'Gtk', '3.0') udev_file = '42-logitech-unify-permissions.rules' if _log.isEnabledFor(_WARNING) \ and not os.path.isfile('/etc/udev/rules.d/' + udev_file) \ and not os.path.isfile('/usr/lib/udev/rules.d/' + udev_file) \ and not os.path.isfile('/usr/local/lib/udev/rules.d/' + udev_file): _log.warning('Solaar udev file not found in expected location') _log.warning( 'See https://pwr-solaar.github.io/Solaar/installation for more information' ) try: import solaar.ui as ui import solaar.listener as listener listener.setup_scanner(ui.status_changed, ui.error_dialog) import solaar.upower as _upower if args.restart_on_wake_up: _upower.watch(listener.start_all, listener.stop_all) else: _upower.watch(lambda: listener.ping_all(True)) # main UI event loop ui.run_loop(listener.start_all, listener.stop_all, args.window != 'only', args.window != 'hide') except Exception: import sys from traceback import format_exc sys.exit('%s: error: %s' % (NAME.lower(), format_exc()))