2021-02-05 21:05:02 +00:00
|
|
|
diff --git a/base/module.py b/base/module.py
|
|
|
|
index dd3efa3..04ac5b8 100644
|
|
|
|
--- a/base/module.py
|
|
|
|
+++ b/base/module.py
|
|
|
|
@@ -432,6 +432,12 @@ class Module(object):
|
|
|
|
if show_usage is not None:
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
+ if mode == GUI_MODE:
|
|
|
|
+ if not utils.canEnterGUIMode4():
|
|
|
|
+ log.warn("GUI mode not available - switching to interactive mode.")
|
|
|
|
+ mode = INTERACTIVE_MODE
|
|
|
|
+ ui_toolkit = 'none'
|
2020-10-15 10:26:13 +00:00
|
|
|
+
|
2021-02-05 21:05:02 +00:00
|
|
|
self.mode = mode
|
|
|
|
return opts, device_uri, printer_name, mode, ui_toolkit, lang
|
|
|
|
|
2020-10-15 10:26:13 +00:00
|
|
|
diff --git a/base/utils.py b/base/utils.py
|
2021-02-05 21:05:02 +00:00
|
|
|
index 98437a3..9b8813b 100644
|
2020-10-15 10:26:13 +00:00
|
|
|
--- a/base/utils.py
|
|
|
|
+++ b/base/utils.py
|
2021-02-05 21:05:02 +00:00
|
|
|
@@ -722,6 +722,15 @@ def canEnterGUIMode4(): # qt4
|
|
|
|
log.warn(e)
|
|
|
|
return False
|
|
|
|
|
|
|
|
+ try:
|
|
|
|
+ import ui4
|
|
|
|
+ except ImportError:
|
|
|
|
+ try:
|
|
|
|
+ import ui5
|
|
|
|
+ except ImportError as e:
|
|
|
|
+ log.warn(e)
|
|
|
|
+ return False
|
|
|
|
+
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
@@ -734,6 +743,11 @@ def checkPyQtImport(): # qt3
|
2020-10-15 10:26:13 +00:00
|
|
|
if os.getenv('DISPLAY') and os.getenv('STARTED_FROM_MENU'):
|
|
|
|
no_qt_message_gtk()
|
2021-02-05 21:05:02 +00:00
|
|
|
|
2020-10-15 10:26:13 +00:00
|
|
|
+ try:
|
|
|
|
+ import ui
|
|
|
|
+ except ImportError:
|
|
|
|
+ return False
|
|
|
|
+
|
|
|
|
log.error("PyQt not installed. GUI not available. Exiting.")
|
|
|
|
return False
|
2021-02-05 21:05:02 +00:00
|
|
|
|
|
|
|
@@ -781,11 +795,13 @@ def checkPyQtImport4():
|
|
|
|
import PyQt4
|
|
|
|
import ui4
|
|
|
|
except ImportError:
|
|
|
|
- import PyQt5
|
|
|
|
- import ui5
|
|
|
|
- else:
|
2020-10-15 10:26:13 +00:00
|
|
|
- log.debug("HPLIP is not installed properly or is installed without graphical support. Please reinstall HPLIP again")
|
2021-02-05 21:05:02 +00:00
|
|
|
- return False
|
2020-10-15 10:26:13 +00:00
|
|
|
+ try:
|
2021-02-05 21:05:02 +00:00
|
|
|
+ import PyQt5
|
|
|
|
+ import ui5
|
|
|
|
+ except ImportError:
|
|
|
|
+ log.debug('GUI not available.')
|
|
|
|
+ return False
|
2020-10-15 10:26:13 +00:00
|
|
|
+
|
2021-02-05 21:05:02 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
# def checkPyQtImport5():
|
2020-10-15 10:26:13 +00:00
|
|
|
diff --git a/fab.py b/fab.py
|
2021-02-05 21:05:02 +00:00
|
|
|
index 5577af5..194ceed 100755
|
2020-10-15 10:26:13 +00:00
|
|
|
--- a/fab.py
|
|
|
|
+++ b/fab.py
|
2021-02-05 21:05:02 +00:00
|
|
|
@@ -776,14 +776,15 @@ mod.setUsage(module.USAGE_FLAG_NONE)
|
|
|
|
opts, device_uri, printer_name, mode, ui_toolkit, loc = \
|
|
|
|
mod.parseStdOpts(handle_device_printer=False)
|
|
|
|
|
|
|
|
-if ui_toolkit == 'qt3':
|
|
|
|
- if not utils.canEnterGUIMode():
|
|
|
|
- log.error("%s GUI mode requires GUI support (try running with --qt4). Entering interactive mode." % __mod__)
|
|
|
|
- mode = INTERACTIVE_MODE
|
|
|
|
-else:
|
|
|
|
- if not utils.canEnterGUIMode4():
|
|
|
|
- log.error("%s GUI mode requires GUI support (try running with --qt3). Entering interactive mode." % __mod__)
|
|
|
|
- mode = INTERACTIVE_MODE
|
|
|
|
+if ui_toolkit != 'none':
|
|
|
|
+ if ui_toolkit == 'qt3':
|
|
|
|
+ if not utils.canEnterGUIMode():
|
|
|
|
+ log.error("%s GUI mode requires GUI support (try running with --qt4). Entering interactive mode." % __mod__)
|
|
|
|
+ mode = INTERACTIVE_MODE
|
|
|
|
+ else:
|
|
|
|
+ if not utils.canEnterGUIMode4():
|
|
|
|
+ log.error("%s GUI mode requires GUI support (try running with --qt3). Entering interactive mode." % __mod__)
|
|
|
|
+ mode = INTERACTIVE_MODE
|
|
|
|
|
|
|
|
|
|
|
|
if mode == GUI_MODE:
|