hplip/hplip-ui-optional.patch

274 lines
9.5 KiB
Diff
Raw Normal View History

diff --git a/align.py b/align.py
index c5a66fe..9067676 100755
--- a/align.py
+++ b/align.py
@@ -241,8 +241,13 @@ try:
# log.error("Unable to load Qt4 support. Is it installed?")
# sys.exit(1)
QApplication, ui_package = utils.import_dialog(ui_toolkit)
- ui = import_module(ui_package + ".aligndialog")
+ try:
+ ui = import_module(ui_package + ".aligndialog")
+ except ModuleNotFoundError:
+ log.error('HPLIP GUI is not available - use interactive mode '
+ '(option \'-i\') or install hplip-gui package.')
+ sys.exit(1)
#try:
if 1:
diff --git a/base/queues.py b/base/queues.py
index 04c37b1..dec7fe9 100755
--- a/base/queues.py
+++ b/base/queues.py
@@ -375,8 +375,14 @@ def main_function(passwordObj = None, mode = GUI_MODE, ui_toolkit= UI_TOOLKIT_QT
sys.exit(1)
QApplication, ui_package = utils.import_dialog(ui_toolkit)
- ui = import_module(ui_package + ".queuesconf")
- setupdialog = import_module(ui_package + ".setupdialog")
+
+ try:
+ ui = import_module(ui_package + ".queuesconf")
+ setupdialog = import_module(ui_package + ".setupdialog")
+ except ModuleNotFoundError:
+ log.error('HPLIP GUI is not available - use interactive mode '
+ '(option \'-i\') or install hplip-gui package.')
+ sys.exit(1)
app = QApplication(sys.argv)
dialog = ui.QueuesDiagnose(None, "","",QUEUES_MSG_SENDING,passwordObj)
diff --git a/base/utils.py b/base/utils.py
index cde819f..0d6e9ff 100644
--- a/base/utils.py
+++ b/base/utils.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# (c) Copyright 2001-2018 HP Development Company, L.P.
@@ -734,6 +734,13 @@ def checkPyQtImport(): # qt3
if os.getenv('DISPLAY') and os.getenv('STARTED_FROM_MENU'):
no_qt_message_gtk()
+ # hplip-gui sub-package (Fedora)
+ try:
+ import ui
+ except ImportError:
+ log.error("hplip-gui not installed. GUI not available. Exiting.")
+ return False
+
log.error("PyQt not installed. GUI not available. Exiting.")
return False
@@ -784,7 +791,8 @@ def checkPyQtImport4():
import PyQt5
import ui5
else:
- log.debug("HPLIP is not installed properly or is installed without graphical support. Please reinstall HPLIP again")
+ # hplip-gui sub-package (Fedora) requires python3-qt5
+ log.error("Install the hplip-gui package for graphical support.")
return False
return True
@@ -2456,6 +2464,7 @@ def checkPyQtImport45():
except ImportError as e:
log.debug(e)
+ log.error("Install the hplip-gui package for graphical support.")
raise ImportError("GUI Modules PyQt4 and PyQt5 are not installed")
@@ -2477,6 +2486,7 @@ def import_dialog(ui_toolkit):
return (QApplication, "ui4")
except ImportError as e:
log.error(e)
+ log.error("Unable to load Qt support. Is hplip-gui package installed?")
sys.exit(1)
elif ui_toolkit == "qt5":
try:
@@ -2485,9 +2495,7 @@ def import_dialog(ui_toolkit):
return (QApplication, "ui5")
except ImportError as e:
log.error(e)
- sys.exit(1)
- else:
- log.error("Unable to load Qt support. Is it installed?")
+ log.error("Unable to load Qt support. Is hplip-gui package installed?")
sys.exit(1)
diff --git a/clean.py b/clean.py
index 3d41f04..0141f23 100755
--- a/clean.py
+++ b/clean.py
@@ -193,8 +193,13 @@ try:
else:
QApplication, ui_package = utils.import_dialog(ui_toolkit)
- ui = import_module(ui_package + ".cleandialog")
+ try:
+ ui = import_module(ui_package + ".cleandialog")
+ except ModuleNotFoundError:
+ log.error('HPLIP GUI is not available - use interactive mode '
+ '(option \'-i\') or install hplip-gui package.')
+ sys.exit(1)
#try:
if 1:
diff --git a/diagnose_plugin.py b/diagnose_plugin.py
index e4e6ebd..1bcd8c3 100755
--- a/diagnose_plugin.py
+++ b/diagnose_plugin.py
@@ -94,7 +94,14 @@ if mode == GUI_MODE:
# sys.exit(1)
QApplication, ui_package = utils.import_dialog(ui_toolkit)
- ui = import_module(ui_package + ".plugindiagnose")
+
+ try:
+ ui = import_module(ui_package + ".plugindiagnose")
+ except ModuleNotFoundError:
+ log.error('HPLIP GUI is not available - use interactive mode '
+ '(option \'-i\') or install hplip-gui package.')
+ sys.exit(1)
+
from installer import pluginhandler
app = QApplication(sys.argv)
diff --git a/fab.py b/fab.py
index 9bd6166..e11ebc4 100755
--- a/fab.py
+++ b/fab.py
@@ -854,8 +854,13 @@ if mode == GUI_MODE:
else: # qt4
QApplication, ui_package = utils.import_dialog(ui_toolkit)
- ui = import_module(ui_package + ".fabwindow")
+ try:
+ ui = import_module(ui_package + ".fabwindow")
+ except ModuleNotFoundError:
+ log.error('HPLIP GUI is not available - use interactive mode '
+ '(option \'-i\') or install hplip-gui package.')
+ sys.exit(1)
log.set_module("hp-fab(qt4)")
diff --git a/firmware.py b/firmware.py
index 33e044d..a38058b 100755
--- a/firmware.py
+++ b/firmware.py
@@ -118,7 +118,13 @@ try:
# log.error("Unable to load Qt4 support. Is it installed?")
# sys.exit(1)
QApplication, ui_package = utils.import_dialog(ui_toolkit)
- ui = import_module(ui_package + ".firmwaredialog")
+
+ try:
+ ui = import_module(ui_package + ".firmwaredialog")
+ except ModuleNotFoundError:
+ log.error('HPLIP GUI is not available - use interactive mode '
+ '(option \'-i\') or install hplip-gui package.')
+ sys.exit(1)
if ui_toolkit == 'qt3':
try:
diff --git a/info.py b/info.py
index 6c28531..5b05eda 100755
--- a/info.py
+++ b/info.py
@@ -172,7 +172,13 @@ try:
else: # GUI mode
QApplication, ui_package = utils.import_dialog(ui_toolkit)
- ui = import_module(ui_package + ".infodialog")
+
+ try:
+ ui = import_module(ui_package + ".infodialog")
+ except ModuleNotFoundError:
+ log.error('HPLIP GUI is not available - use interactive mode '
+ '(option \'-i\') or install hplip-gui package.')
+ sys.exit(1)
if 1:
app = QApplication(sys.argv)
diff --git a/plugin.py b/plugin.py
index f54f726..58d6006 100755
--- a/plugin.py
+++ b/plugin.py
@@ -252,7 +252,14 @@ if mode == GUI_MODE:
# clean_exit(1)
QApplication, ui_package = utils.import_dialog(ui_toolkit)
- ui = import_module(ui_package + ".plugindialog")
+
+ try:
+ ui = import_module(ui_package + ".plugindialog")
+ except ModuleNotFoundError:
+ log.error('HPLIP GUI is not available - use interactive mode '
+ '(option \'-i\') or install hplip-gui package.')
+ sys.exit(1)
+
if ui_toolkit == "qt5":
from PyQt5.QtWidgets import QMessageBox
elif ui_toolkit == "qt4":
diff --git a/sendfax.py b/sendfax.py
index 491c8f9..0815ee7 100755
--- a/sendfax.py
+++ b/sendfax.py
@@ -211,7 +211,13 @@ if mode == GUI_MODE:
# sys.exit(1)
QApplication, ui_package = utils.import_dialog(ui_toolkit)
- ui = import_module(ui_package + ".sendfaxdialog")
+
+ try:
+ ui = import_module(ui_package + ".sendfaxdialog")
+ except ModuleNotFoundError:
+ log.error('HPLIP GUI is not available - use interactive mode '
+ '(option \'-i\') or install hplip-gui package.')
+ sys.exit(1)
app = QApplication(sys.argv)
dlg = ui.SendFaxDialog(None, printer_name, device_uri, mod.args)
diff --git a/setup.py b/setup.py
index 2608f95..b09a8ef 100755
--- a/setup.py
+++ b/setup.py
@@ -310,7 +310,12 @@ if mode == GUI_MODE:
# clean_exit(1)
QApplication, ui_package = utils.import_dialog(ui_toolkit)
- ui = import_module(ui_package + ".setupdialog")
+ try:
+ ui = import_module(ui_package + ".setupdialog")
+ except ModuleNotFoundError:
+ log.error('HPLIP GUI is not available - use interactive mode '
+ '(option \'-i\') or install hplip-gui package.')
+ sys.exit(1)
app = QApplication(sys.argv)
log.debug("Sys.argv=%s printer_name=%s param=%s jd_port=%s device_uri=%s remove=%s" % (sys.argv, printer_name, param, jd_port, device_uri, remove))
diff --git a/testpage.py b/testpage.py
index a5ed2bc..2a707a1 100755
--- a/testpage.py
+++ b/testpage.py
@@ -77,7 +77,13 @@ try:
# log.error("Unable to load Qt4 support. Is it installed?")
# sys.exit(1)
QApplication, ui_package = utils.import_dialog(ui_toolkit)
- ui = import_module(ui_package + ".printtestpagedialog")
+
+ try:
+ ui = import_module(ui_package + ".printtestpagedialog")
+ except ModuleNotFoundError:
+ log.error('HPLIP GUI is not available - use interactive mode '
+ '(option \'-i\') or install hplip-gui package.')
+ sys.exit(1)
log.set_module("%s(UI)" % __mod__)