hplip/hplip-ui-optional.patch

97 lines
3.0 KiB
Diff
Raw Normal View History

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'
+
self.mode = mode
return opts, device_uri, printer_name, mode, ui_toolkit, lang
diff --git a/base/utils.py b/base/utils.py
index 98437a3..9b8813b 100644
--- a/base/utils.py
+++ b/base/utils.py
@@ -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
if os.getenv('DISPLAY') and os.getenv('STARTED_FROM_MENU'):
no_qt_message_gtk()
+ try:
+ import ui
+ except ImportError:
+ return False
+
log.error("PyQt not installed. GUI not available. Exiting.")
return False
@@ -781,11 +795,13 @@ def checkPyQtImport4():
import PyQt4
import ui4
except ImportError:
- import PyQt5
- import ui5
- else:
- log.debug("HPLIP is not installed properly or is installed without graphical support. Please reinstall HPLIP again")
- return False
+ try:
+ import PyQt5
+ import ui5
+ except ImportError:
+ log.debug('GUI not available.')
+ return False
+
return True
# def checkPyQtImport5():
diff --git a/fab.py b/fab.py
index 5577af5..194ceed 100755
--- a/fab.py
+++ b/fab.py
@@ -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: