[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Pki-devel] [PATCH] 813 Improved SystemConfigService.configure() error message.



On 8/8/2016 1:42 PM, Endi Sukma Dewata wrote:
The pkispawn has been modified to improve the way it displays the
error message returned by SystemConfigService.configure(). If the
method throws a PKIException, the response is returned as a JSON
message, then pkispawn will parse it and display the error message
only. For other exceptions pkispawn will display the entire HTML
message returned by Tomcat.

https://fedorahosted.org/pki/ticket/2399

ACKed by alee (thanks!) with some adjustments. Pushed to master.

--
Endi S. Dewata
>From a94f3ff69c6ca49ad02da921893e9dac92e57358 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata redhat com>
Date: Mon, 8 Aug 2016 19:19:16 +0200
Subject: [PATCH] Improved SystemConfigService.configure() error message.

The pkispawn has been modified to improve the way it displays the
error message returned by SystemConfigService.configure(). If the
method throws a PKIException, the response is returned as a JSON
message, so pkispawn will parse it and display the actual error
message. For other exceptions pkispawn will display the entire
HTML message returned by Tomcat.

https://fedorahosted.org/pki/ticket/2399
---
 .../python/pki/server/deployment/pkihelper.py      | 23 +---------------------
 base/server/sbin/pkispawn                          | 20 +++++++++++++++++--
 2 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/base/server/python/pki/server/deployment/pkihelper.py b/base/server/python/pki/server/deployment/pkihelper.py
index 8a1dbddb5615e81bfaa498615f4192e05fbc2b4a..b6eacf1cea121ede30795289d953baf496c5a22f 100644
--- a/base/server/python/pki/server/deployment/pkihelper.py
+++ b/base/server/python/pki/server/deployment/pkihelper.py
@@ -3959,28 +3959,7 @@ class ConfigClient:
                     admin_cert = response['adminCert']['cert']
                     self.process_admin_cert(admin_cert)
 
-        except Exception as e:
-            config.pki_log.error(
-                log.PKI_CONFIG_JAVA_CONFIGURATION_EXCEPTION + " " + str(e),
-                extra=config.PKI_INDENTATION_LEVEL_2)
-
-            if hasattr(e, 'response'):
-                text = e.response.text  # pylint: disable=E1101
-                try:
-                    root = ET.fromstring(text)
-                except ET.ParseError as pe:
-                    config.pki_log.error(
-                        "ParseError: %s: %s " % (pe, text),
-                        extra=config.PKI_INDENTATION_LEVEL_2)
-                    raise
-
-                if root.tag == 'PKIException':
-                    message = root.findall('.//Message')[0].text
-                    if message is not None:
-                        config.pki_log.error(
-                            log.PKI_CONFIG_JAVA_CONFIGURATION_EXCEPTION + " " +
-                            message,
-                            extra=config.PKI_INDENTATION_LEVEL_2)
+        except:
 
             raise
 
diff --git a/base/server/sbin/pkispawn b/base/server/sbin/pkispawn
index 13139fa23fcae4b256e248fcd1b552448d4d039c..c87c49a3d2ebb8901b34cf4ccfcfcc245a32235b 100755
--- a/base/server/sbin/pkispawn
+++ b/base/server/sbin/pkispawn
@@ -527,8 +527,24 @@ def main(argv):
 
             scriptlet.spawn(deployer)
 
-    # pylint: disable=W0703
-    except Exception as e:
+    except requests.HTTPError as e:
+        r = e.response
+        print()
+
+        print('Installation failed:')
+        if r.headers['content-type'] == 'application/json':
+            data = r.json()
+            print('%s: %s' % (data['ClassName'], data['Message']))
+        else:
+            print(r.text)
+
+        print()
+        print('Please check the %s logs in %s.' %
+              (config.pki_subsystem, deployer.mdict['pki_subsystem_log_path']))
+
+        sys.exit(1)
+
+    except Exception as e:  # pylint: disable=broad-except
         log_error_details()
         print()
         print("Installation failed: %s" % e)
-- 
2.5.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]