From a4ec73dacfdab25068559e4e48d89ca7c7ff8bf3 Mon Sep 17 00:00:00 2001
From: Christian Heimes <cheimes@redhat.com>
Date: Mon, 20 Jul 2015 11:11:35 +0200
Subject: [PATCH 18/18] Replace Exception.message with str(exc)

Python 3 has deprecated and remove Exception.message. Instead we should
simply use string formatting to print the message of an Exception.

>>> import pki
>>> pki.PKIException('msg')
PKIException('msg',)
>>> pki.PKIException('msg').message
'msg'
>>> str(pki.PKIException('msg'))
'msg'
>>> '%s' % pki.PKIException('msg')
'msg'
---
 base/common/python/pki/upgrade.py        | 10 +++++-----
 base/server/python/pki/server/upgrade.py |  9 ++++-----
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/base/common/python/pki/upgrade.py b/base/common/python/pki/upgrade.py
index 5534069c1d61158f62b36923854296fe51878145..30911613aab42c045999943798a0ab096108005e 100644
--- a/base/common/python/pki/upgrade.py
+++ b/base/common/python/pki/upgrade.py
@@ -307,7 +307,7 @@ class PKIUpgradeScriptlet(object):
             if verbose:
                 traceback.print_exc()
             else:
-                print 'ERROR: ' + e.message
+                print 'ERROR: %s' % e
 
             message = 'Failed upgrading system.'
             if self.upgrader.silent:
@@ -320,7 +320,7 @@ class PKIUpgradeScriptlet(object):
                 if result == 'y':
                     return
 
-            raise pki.PKIException('Upgrade failed: ' + e.message, e)
+            raise pki.PKIException('Upgrade failed: %s' % e, e)
 
     def revert(self):
 
@@ -631,7 +631,7 @@ class PKIUpgrader(object):
                 if verbose:
                     traceback.print_exc()
                 else:
-                    print e.message
+                    print e
 
                 print
 
@@ -693,12 +693,12 @@ class PKIUpgrader(object):
 
                 print
 
-                message = 'Revert failed: ' + e.message
+                message = 'Revert failed: %s' % e
 
                 if verbose:
                     traceback.print_exc()
                 else:
-                    print e.message
+                    print e
 
                 print
 
diff --git a/base/server/python/pki/server/upgrade.py b/base/server/python/pki/server/upgrade.py
index c9426a07ce81cdad734072fedb0d60da4a988a83..1db945e12a08fd480b00b668afaef3b7fb37c363 100644
--- a/base/server/python/pki/server/upgrade.py
+++ b/base/server/python/pki/server/upgrade.py
@@ -95,7 +95,7 @@ class PKIServerUpgradeScriptlet(pki.upgrade.PKIUpgradeScriptlet):
                 if verbose:
                     traceback.print_exc()
                 else:
-                    print 'ERROR: ' + e.message
+                    print 'ERROR: %s' % e
 
                 message = 'Failed upgrading ' + str(instance) + ' instance.'
                 if self.upgrader.silent:
@@ -109,8 +109,7 @@ class PKIServerUpgradeScriptlet(pki.upgrade.PKIUpgradeScriptlet):
                         continue
 
                 raise pki.server.PKIServerException(
-                    'Upgrade failed in ' + str(instance) + ': ' + e.message,
-                    e, instance)
+                    'Upgrade failed in %s: %s' % (instance, e), e, instance)
 
     def upgrade_subsystems(self, instance):
 
@@ -132,7 +131,7 @@ class PKIServerUpgradeScriptlet(pki.upgrade.PKIUpgradeScriptlet):
                 if verbose:
                     traceback.print_exc()
                 else:
-                    print 'ERROR: ' + e.message
+                    print 'ERROR: %s' % e
 
                 message = 'Failed upgrading ' + str(subsystem) + ' subsystem.'
                 if self.upgrader.silent:
@@ -146,7 +145,7 @@ class PKIServerUpgradeScriptlet(pki.upgrade.PKIUpgradeScriptlet):
                         continue
 
                 raise pki.server.PKIServerException(
-                    'Upgrade failed in ' + str(subsystem) + ': ' + e.message,
+                    'Upgrade failed in %s: %s' % (subsystem, e),
                     e, instance, subsystem)
 
     def upgrade_subsystem(self, instance, subsystem):
-- 
2.4.3

