From d6b7a484d512f21c353468427f1141f7f237c41e Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Jun 01 2020 07:25:27 +0000 Subject: 1794147 - HP-setup crashes with Python3 ui5 module not found error --- diff --git a/hplip-ui-optional.patch b/hplip-ui-optional.patch index 0710d10..cf4c037 100644 --- a/hplip-ui-optional.patch +++ b/hplip-ui-optional.patch @@ -1,16 +1,24 @@ -diff -up hplip-3.19.6/base/utils.py.ui-optional hplip-3.19.6/base/utils.py ---- hplip-3.19.6/base/utils.py.ui-optional 2019-06-26 15:07:10.000000000 +0200 -+++ hplip-3.19.6/base/utils.py 2019-07-12 08:16:22.390256936 +0200 -@@ -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 +diff --git a/base/utils.py b/base/utils.py +index 98437a3..4192189 100644 +--- a/base/utils.py ++++ b/base/utils.py +@@ -722,6 +722,12 @@ def canEnterGUIMode4(): # qt4 + log.warn(e) + return False + ++ try: ++ import ui ++ except ImportError: ++ log.error('HPLIP UI module not installed - run the command with \'-i\' option for interactive mode or install hplip-gui package.') ++ return False ++ + return True + + +@@ -734,6 +740,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 @@ -20,8 +28,8 @@ diff -up hplip-3.19.6/base/utils.py.ui-optional hplip-3.19.6/base/utils.py + log.error("PyQt not installed. GUI not available. Exiting.") return False - -@@ -784,7 +791,8 @@ def checkPyQtImport4(): + +@@ -784,7 +797,8 @@ def checkPyQtImport4(): import PyQt5 import ui5 else: @@ -30,16 +38,16 @@ diff -up hplip-3.19.6/base/utils.py.ui-optional hplip-3.19.6/base/utils.py + log.error("Install the hplip-gui package for graphical support.") return False return True - -@@ -2456,6 +2464,7 @@ def checkPyQtImport45(): + +@@ -2456,6 +2470,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): + + +@@ -2477,6 +2492,7 @@ def import_dialog(ui_toolkit): return (QApplication, "ui4") except ImportError as e: log.error(e) @@ -47,7 +55,7 @@ diff -up hplip-3.19.6/base/utils.py.ui-optional hplip-3.19.6/base/utils.py sys.exit(1) elif ui_toolkit == "qt5": try: -@@ -2485,9 +2495,7 @@ def import_dialog(ui_toolkit): +@@ -2485,9 +2501,7 @@ def import_dialog(ui_toolkit): return (QApplication, "ui5") except ImportError as e: log.error(e) @@ -56,14 +64,15 @@ diff -up hplip-3.19.6/base/utils.py.ui-optional hplip-3.19.6/base/utils.py - 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 -up hplip-3.19.6/plugin.py.ui-optional hplip-3.19.6/plugin.py ---- hplip-3.19.6/plugin.py.ui-optional 2019-06-26 15:07:10.000000000 +0200 -+++ hplip-3.19.6/plugin.py 2019-07-12 08:15:03.731933177 +0200 + + +diff --git a/plugin.py b/plugin.py +index c833c55..74f93ef 100755 +--- a/plugin.py ++++ b/plugin.py @@ -252,7 +252,11 @@ if mode == GUI_MODE: # clean_exit(1) - + QApplication, ui_package = utils.import_dialog(ui_toolkit) - ui = import_module(ui_package + ".plugindialog") + try: @@ -74,3 +83,21 @@ diff -up hplip-3.19.6/plugin.py.ui-optional hplip-3.19.6/plugin.py if ui_toolkit == "qt5": from PyQt5.QtWidgets import QMessageBox elif ui_toolkit == "qt4": +diff --git a/setup.py b/setup.py +index ba1b519..ac4afa2 100755 +--- a/setup.py ++++ b/setup.py +@@ -218,11 +218,11 @@ if mode == GUI_MODE: + log.warning("-p or -f option is not supported") + if ui_toolkit == 'qt3': + if not utils.canEnterGUIMode(): +- log.error("%s requires GUI support (try running with --qt4). Also, try using interactive (-i) mode." % __mod__) ++ log.error("%s requires GUI support (try running with --qt3). Also, try using interactive (-i) mode." % __mod__) + clean_exit(1) + else: + if not utils.canEnterGUIMode4(): +- log.error("%s requires GUI support (try running with --qt3). Also, try using interactive (-i) mode." % __mod__) ++ log.error("%s requires GUI support (try running with --qt4). Also, try using interactive (-i) mode." % __mod__) + clean_exit(1) + + if mode == GUI_MODE: diff --git a/hplip.spec b/hplip.spec index 3f2578c..06c406d 100644 --- a/hplip.spec +++ b/hplip.spec @@ -7,7 +7,7 @@ Summary: HP Linux Imaging and Printing Project Name: hplip Version: 3.20.5 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2+ and MIT and BSD and IJG and Public Domain and GPLv2+ with exceptions and ISC Url: https://developers.hp.com/hp-linux-imaging-and-printing @@ -702,6 +702,9 @@ rm -f %{buildroot}%{_sysconfdir}/xdg/autostart/hplip-systray.desktop %config(noreplace) %{_sysconfdir}/sane.d/dll.d/hpaio %changelog +* Mon Jun 01 2020 Zdenek Dohnal - 3.20.5-4 +- 1794147 - HP-setup crashes with Python3 ui5 module not found error + * Tue May 26 2020 Miro HronĨok - 3.20.5-3 - Rebuilt for Python 3.9