[blivet:master 6/6] Update to the new raise syntax

mulhern amulhern at redhat.com
Fri Mar 21 20:17:15 UTC 2014


From: David Shea <dshea at redhat.com>

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/devices.py  |  4 ++--
 blivet/fcoe.py     |  2 +-
 blivet/iscsi.py    | 14 +++++++-------
 blivet/platform.py |  4 ++--
 blivet/pyudev.py   |  2 +-
 blivet/zfcp.py     | 55 +++++++++++++++++++++++++++---------------------------
 6 files changed, 40 insertions(+), 41 deletions(-)

diff --git a/blivet/devices.py b/blivet/devices.py
index 01c13d6..c602026 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -3027,10 +3027,10 @@ class MDRaidArrayDevice(StorageDevice):
         if (not exists and parents and len(parents) < self.level.min_members):
             for dev in self.parents:
                 dev.removeChild()
-            raise DeviceError, P_("A %(raidLevel)s set requires at least %(minMembers)d member",
+            raise DeviceError(P_("A %(raidLevel)s set requires at least %(minMembers)d member",
                                  "A %(raidLevel)s set requires at least %(minMembers)d members",
                                  self.level.min_members) % \
-                                 {"raidLevel": self.level, "minMembers": self.level.min_members}
+                                 {"raidLevel": self.level, "minMembers": self.level.min_members})
 
         self.uuid = uuid
         self._totalDevices = util.numeric_type(totalDevices)
diff --git a/blivet/fcoe.py b/blivet/fcoe.py
index 854bd69..aa4618f 100644
--- a/blivet/fcoe.py
+++ b/blivet/fcoe.py
@@ -108,7 +108,7 @@ class fcoe(object):
            Returns error message, or empty string if succeeded.
         """
         if not has_fcoe():
-            raise IOError, _("FCoE not available")
+            raise IOError(_("FCoE not available"))
 
         log.info("Activating FCoE SAN attached to %s, dcb: %s autovlan: %s",
                  nic, dcb, auto_vlan)
diff --git a/blivet/iscsi.py b/blivet/iscsi.py
index b48a7c2..06b1f90 100644
--- a/blivet/iscsi.py
+++ b/blivet/iscsi.py
@@ -101,9 +101,9 @@ class iscsi(object):
 
     def _setInitiator(self, val):
         if self.initiatorSet and val != self._initiator:
-            raise ValueError, _("Unable to change iSCSI initiator name once set")
+            raise ValueError(_("Unable to change iSCSI initiator name once set"))
         if len(val) == 0:
-            raise ValueError, _("Must provide an iSCSI initiator name")
+            raise ValueError(_("Must provide an iSCSI initiator name"))
         self._initiator = val
 
     initiator = property(_getInitiator, _setInitiator)
@@ -260,9 +260,9 @@ class iscsi(object):
         authinfo = None
 
         if not has_iscsi():
-            raise IOError, _("iSCSI not available")
+            raise IOError(_("iSCSI not available"))
         if self._initiator == "":
-            raise ValueError, _("No initiator name set")
+            raise ValueError(_("No initiator name set"))
 
         if self.active_nodes((ipaddr, port)):
             log.debug("iSCSI: skipping discovery of %s:%s due to active nodes",
@@ -330,7 +330,7 @@ class iscsi(object):
 
         found_nodes = self.discover(ipaddr, port, user, pw, user_in, pw_in)
         if found_nodes == None:
-            raise IOError, _("No iSCSI nodes discovered")
+            raise IOError(_("No iSCSI nodes discovered"))
 
         for node in found_nodes:
             if target and target != node.name:
@@ -350,10 +350,10 @@ class iscsi(object):
                 logged_in = logged_in +1
 
         if found == 0:
-            raise IOError, _("No new iSCSI nodes discovered")
+            raise IOError(_("No new iSCSI nodes discovered"))
 
         if logged_in == 0:
-            raise IOError, _("Could not log in to any of the discovered nodes")
+            raise IOError(_("Could not log in to any of the discovered nodes"))
 
         self.stabilize()
 
diff --git a/blivet/platform.py b/blivet/platform.py
index 61b8da7..98472e6 100644
--- a/blivet/platform.py
+++ b/blivet/platform.py
@@ -398,7 +398,7 @@ def getPlatform():
         elif ppcMachine == "PS3":
             return PS3()
         else:
-            raise SystemError, "Unsupported PPC machine type: %s" % ppcMachine
+            raise SystemError("Unsupported PPC machine type: %s" % ppcMachine)
     elif arch.isS390():
         return S390()
     elif arch.isEfi():
@@ -417,7 +417,7 @@ def getPlatform():
         else:
             return ARM()
     else:
-        raise SystemError, "Could not determine system architecture."
+        raise SystemError("Could not determine system architecture.")
 
 def reset_platform():
     global platform
diff --git a/blivet/pyudev.py b/blivet/pyudev.py
index 705b93d..c26e229 100644
--- a/blivet/pyudev.py
+++ b/blivet/pyudev.py
@@ -36,7 +36,7 @@ somajor = 1
 libudev = find_library(name=name, somajor=somajor)
 
 if not libudev or not os.path.exists(libudev):
-    raise ImportError, "No library named %s.%d" % (name, somajor)
+    raise ImportError("No library named %s.%d" % (name, somajor))
 
 # load the udev library
 libudev = CDLL(libudev)
diff --git a/blivet/zfcp.py b/blivet/zfcp.py
index 618c4ff..5aa3718 100644
--- a/blivet/zfcp.py
+++ b/blivet/zfcp.py
@@ -45,11 +45,11 @@ class ZFCPDevice:
         self.fcplun = self.sanitizeFCPLInput(fcplun)
 
         if not self.checkValidDevice(self.devnum):
-            raise ValueError, _("You have not specified a device number or the number is invalid")
+            raise ValueError(_("You have not specified a device number or the number is invalid"))
         if not self.checkValidWWPN(self.wwpn):
-            raise ValueError, _("You have not specified a worldwide port name or the name is invalid.")
+            raise ValueError(_("You have not specified a worldwide port name or the name is invalid."))
         if not self.checkValidFCPLun(self.fcplun):
-            raise ValueError, _("You have not specified a FCP LUN or the number is invalid.")
+            raise ValueError(_("You have not specified a FCP LUN or the number is invalid."))
 
     def __str__(self):
         return "%s %s %s" %(self.devnum, self.wwpn, self.fcplun)
@@ -125,9 +125,8 @@ class ZFCPDevice:
             util.run_program(["zfcp_cio_free", "-d", self.devnum])
 
         if not os.path.exists(online):
-            raise ValueError, _(
-                "zFCP device %s not found, not even in device ignore list."
-                %(self.devnum,))
+            raise ValueError(_("zFCP device %s not found, not even in device ignore list." % \
+                    (self.devnum,)))
 
         try:
             f = open(online, "r")
@@ -136,9 +135,9 @@ class ZFCPDevice:
             if devonline != "1":
                 loggedWriteLineToFile(online, "1")
         except IOError as e:
-            raise ValueError, _("Could not set zFCP device %(devnum)s "
+            raise ValueError(_("Could not set zFCP device %(devnum)s "
                                 "online (%(e)s).") \
-                              % {'devnum': self.devnum, 'e': e}
+                              % {'devnum': self.devnum, 'e': e})
 
         if not os.path.exists(portdir):
             if os.path.exists(portadd):
@@ -147,16 +146,16 @@ class ZFCPDevice:
                     loggedWriteLineToFile(portadd, self.wwpn)
                     udev_settle()
                 except IOError as e:
-                    raise ValueError, _("Could not add WWPN %(wwpn)s to zFCP "
+                    raise ValueError(_("Could not add WWPN %(wwpn)s to zFCP "
                                         "device %(devnum)s (%(e)s).") \
                                       % {'wwpn': self.wwpn,
                                          'devnum': self.devnum,
-                                         'e': e}
+                                         'e': e})
             else:
                 # newer zfcp sysfs interface with auto port scan
-                raise ValueError, _("WWPN %(wwpn)s not found at zFCP device "
+                raise ValueError(_("WWPN %(wwpn)s not found at zFCP device "
                                     "%(devnum)s.") % {'wwpn': self.wwpn,
-                                                      'devnum': self.devnum}
+                                                      'devnum': self.devnum})
         else:
             if os.path.exists(portadd):
                 # older zfcp sysfs interface
@@ -169,17 +168,17 @@ class ZFCPDevice:
                 loggedWriteLineToFile(unitadd, self.fcplun)
                 udev_settle()
             except IOError as e:
-                raise ValueError, _("Could not add LUN %(fcplun)s to WWPN "
+                raise ValueError(_("Could not add LUN %(fcplun)s to WWPN "
                                     "%(wwpn)s on zFCP device %(devnum)s "
                                     "(%(e)s).") \
                                   % {'fcplun': self.fcplun, 'wwpn': self.wwpn,
-                                     'devnum': self.devnum, 'e': e}
+                                     'devnum': self.devnum, 'e': e})
         else:
-            raise ValueError, _("LUN %(fcplun)s at WWPN %(wwpn)s on zFCP "
+            raise ValueError(_("LUN %(fcplun)s at WWPN %(wwpn)s on zFCP "
                                 "device %(devnum)s already configured.") \
                               % {'fcplun': self.fcplun,
                                  'wwpn': self.wwpn,
-                                 'devnum': self.devnum}
+                                 'devnum': self.devnum})
 
         fail = "0"
         try:
@@ -187,20 +186,20 @@ class ZFCPDevice:
             fail = f.readline().strip()
             f.close()
         except IOError as e:
-            raise ValueError, _("Could not read failed attribute of LUN "
+            raise ValueError(_("Could not read failed attribute of LUN "
                                 "%(fcplun)s at WWPN %(wwpn)s on zFCP device "
                                 "%(devnum)s (%(e)s).") \
                               % {'fcplun': self.fcplun,
                                  'wwpn': self.wwpn,
                                  'devnum': self.devnum,
-                                 'e': e}
+                                 'e': e})
         if fail != "0":
             self.offlineDevice()
-            raise ValueError, _("Failed LUN %(fcplun)s at WWPN %(wwpn)s on "
+            raise ValueError(_("Failed LUN %(fcplun)s at WWPN %(wwpn)s on "
                                 "zFCP device %(devnum)s removed again.") \
                               % {'fcplun': self.fcplun,
                                  'wwpn': self.wwpn,
-                                 'devnum': self.devnum}
+                                 'devnum': self.devnum})
 
         return True
 
@@ -253,20 +252,20 @@ class ZFCPDevice:
         try:
             self.offlineSCSIDevice()
         except IOError as e:
-            raise ValueError, _("Could not correctly delete SCSI device of "
+            raise ValueError(_("Could not correctly delete SCSI device of "
                                 "zFCP %(devnum)s %(wwpn)s %(fcplun)s "
                                 "(%(e)s).") \
                               % {'devnum': self.devnum, 'wwpn': self.wwpn,
-                                 'fcplun': self.fcplun, 'e': e}
+                                 'fcplun': self.fcplun, 'e': e})
 
         try:
             loggedWriteLineToFile(unitremove, self.fcplun)
         except IOError as e:
-            raise ValueError, _("Could not remove LUN %(fcplun)s at WWPN "
+            raise ValueError(_("Could not remove LUN %(fcplun)s at WWPN "
                                 "%(wwpn)s on zFCP device %(devnum)s "
                                 "(%(e)s).") \
                               % {'fcplun': self.fcplun, 'wwpn': self.wwpn,
-                                 'devnum': self.devnum, 'e': e}
+                                 'devnum': self.devnum, 'e': e})
 
         if os.path.exists(portadd):
             # only try to remove ports with older zfcp sysfs interface
@@ -280,10 +279,10 @@ class ZFCPDevice:
             try:
                 loggedWriteLineToFile(portremove, self.wwpn)
             except IOError as e:
-                raise ValueError, _("Could not remove WWPN %(wwpn)s on zFCP "
+                raise ValueError(_("Could not remove WWPN %(wwpn)s on zFCP "
                                     "device %(devnum)s (%(e)s).") \
                                   % {'wwpn': self.wwpn,
-                                     'devnum': self.devnum, 'e': e}
+                                     'devnum': self.devnum, 'e': e})
 
         if os.path.exists(portadd):
             # older zfcp sysfs interface
@@ -306,9 +305,9 @@ class ZFCPDevice:
         try:
             loggedWriteLineToFile(offline, "0")
         except IOError as e:
-            raise ValueError, _("Could not set zFCP device %(devnum)s "
+            raise ValueError(_("Could not set zFCP device %(devnum)s "
                                 "offline (%(e)s).") \
-                              % {'devnum': self.devnum, 'e': e}
+                              % {'devnum': self.devnum, 'e': e})
 
         return True
 
-- 
1.8.3.1



More information about the anaconda-patches mailing list