Backtrace when run without gtk installed
Created by: jasontibbitts
If you try to bring up the graphical interface without gtk installed, you get a backtrace:
Traceback (most recent call last):
File "/usr/bin/solaar", line 57, in <module>
solaar.gtk.main()
File "/usr/lib/python3.7/site-packages/solaar/gtk.py", line 90, in main
gi.require_version('Gtk', '3.0')
File "/usr/lib64/python3.7/site-packages/gi/__init__.py", line 127, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gtk not available
It does appear that there is code to handle missing modules, but gtk doesn't get imported directly so it wouldn't trigger. Maybe something like this?
diff --git a/lib/solaar/gtk.py b/lib/solaar/gtk.py
index f728420..20683af 100644
--- a/lib/solaar/gtk.py
+++ b/lib/solaar/gtk.py
@@ -87,8 +87,11 @@ def main():
if not args: return
if args.action: return _cli.run(args.action, args.hidraw_path)
- gi = _require('gi', 'python-gi')
- gi.require_version('Gtk', '3.0')
+ try:
+ gi.require_version('Gtk', '3.0')
+ except ValueError:
+ import sys
+ sys.exit("%s: Gtk (version 3) must be installed in order to run the graphical interface." % (NAME))
_require('gi.repository.Gtk', 'gir1.2-gtk-3.0')
try:
Can send a PR if desired, but I don't know if that's the right approach.