From 456809d0eaf9ce64503a6564a5d7a9ce38723fbf Mon Sep 17 00:00:00 2001 From: Hironori Shiina Date: Wed, 24 May 2017 20:24:43 +0900 Subject: [PATCH] Add error information to error messages This patch adds error information to an error message when an SCCI request hit an error for giving more information. The error information can be got from an SCCI response as an Error element. Change-Id: I07fc86909e278ed70f6951505105b382d2b29e76 --- scciclient/irmc/scci.py | 4 +++- scciclient/tests/irmc/test_scci.py | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/scciclient/irmc/scci.py b/scciclient/irmc/scci.py index 7f821f9..d812158 100644 --- a/scciclient/irmc/scci.py +++ b/scciclient/irmc/scci.py @@ -284,11 +284,13 @@ def scci_cmd(host, userid, password, cmd, port=443, auth_method='basic', result_xml = ET.fromstring(r.text) status = result_xml.find("./Value") # severity = result_xml.find("./Severity") + error = result_xml.find("./Error") message = result_xml.find("./Message") if not int(status.text) == 0: raise SCCIClientError( ('SCCI PROTOCOL ERROR, STATUS CODE = %s, ' - 'MESSAGE = %s' % (str(status.text), message.text))) + 'ERROR = %s, MESSAGE = %s' % + (str(status.text), error.text, message.text))) else: return r diff --git a/scciclient/tests/irmc/test_scci.py b/scciclient/tests/irmc/test_scci.py index ff2d645..3b7746b 100644 --- a/scciclient/tests/irmc/test_scci.py +++ b/scciclient/tests/irmc/test_scci.py @@ -380,7 +380,8 @@ class SCCITestCase(testtools.TestCase): client, scci.POWER_SOFT_OFF) self.assertEqual( - 'SCCI PROTOCOL ERROR, STATUS CODE = 31, MESSAGE = Error 31' + 'SCCI PROTOCOL ERROR, STATUS CODE = 31,' + ' ERROR = ServerView Agent not connected, MESSAGE = Error 31' ' (Import of settings in WinSCU XML format failed) occurred', str(e)) @@ -425,7 +426,8 @@ class SCCITestCase(testtools.TestCase): client, scci.POWER_SOFT_CYCLE) self.assertEqual( - 'SCCI PROTOCOL ERROR, STATUS CODE = 31, MESSAGE = Error 31' + 'SCCI PROTOCOL ERROR, STATUS CODE = 31,' + ' ERROR = ServerView Agent not connected, MESSAGE = Error 31' ' (Import of settings in WinSCU XML format failed) occurred', str(e)) @@ -470,7 +472,8 @@ class SCCITestCase(testtools.TestCase): client, scci.POWER_CANCEL_SHUTDOWN) self.assertEqual( - 'SCCI PROTOCOL ERROR, STATUS CODE = 31, MESSAGE = Error 31' + 'SCCI PROTOCOL ERROR, STATUS CODE = 31,' + ' ERROR = ServerView Agent not connected, MESSAGE = Error 31' ' (Import of settings in WinSCU XML format failed) occurred', str(e))