diff mbox

[ovs-dev,5/6] xenserver: Use PEP 3110 exception syntax.

Message ID 1464052831-17278-6-git-send-email-joe@ovn.org
State Accepted
Headers show

Commit Message

Joe Stringer May 24, 2016, 1:20 a.m. UTC
This syntax is usable with both python2.7 and python3, so use it instead
of the outdated syntax.

Signed-off-by: Joe Stringer <joe@ovn.org>
---
 xenserver/opt_xensource_libexec_InterfaceReconfigure.py      |  4 ++--
 .../opt_xensource_libexec_InterfaceReconfigureVswitch.py     |  2 +-
 xenserver/opt_xensource_libexec_interface-reconfigure        | 12 ++++++------
 3 files changed, 9 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigure.py b/xenserver/opt_xensource_libexec_InterfaceReconfigure.py
index 2630077385a2..196c6863af8f 100644
--- a/xenserver/opt_xensource_libexec_InterfaceReconfigure.py
+++ b/xenserver/opt_xensource_libexec_InterfaceReconfigure.py
@@ -730,7 +730,7 @@  def mtu_setting(nw, type, oc):
         try:
             int(mtu)      # Check that the value is an integer
             return mtu
-        except ValueError, x:
+        except ValueError as x:
             log("Invalid value for mtu = %s" % mtu)
 
     return None
@@ -958,7 +958,7 @@  def DatapathFactory():
         network_conf = open(root_prefix() + "/etc/xensource/network.conf", 'r')
         network_backend = network_conf.readline().strip()
         network_conf.close()                
-    except Exception, e:
+    except Exception as e:
         raise Error("failed to determine network backend:" + e)
     
     if network_backend == "bridge":
diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py b/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py
index d9eda6adcf27..c65fb3da44fc 100644
--- a/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py
+++ b/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py
@@ -54,7 +54,7 @@  def netdev_get_driver_name(netdev):
     symlink = '%s/sys/class/net/%s/device/driver' % (root_prefix(), netdev)
     try:
         target = os.readlink(symlink)
-    except OSError, e:
+    except OSError as e:
         log("%s: could not read netdev's driver name (%s)" % (netdev, e))
         return None
 
diff --git a/xenserver/opt_xensource_libexec_interface-reconfigure b/xenserver/opt_xensource_libexec_interface-reconfigure
index eab246c1922a..7bb456b3bc0a 100755
--- a/xenserver/opt_xensource_libexec_interface-reconfigure
+++ b/xenserver/opt_xensource_libexec_interface-reconfigure
@@ -260,7 +260,7 @@  def ipdev_configure_static_routes(interface, oc, f):
         f.attach_child(child)
         child.close()
 
-    except ValueError, e:
+    except ValueError as e:
         log("Error in other-config['static-routes'] format for network %s: %s" % (interface, e))
 
 def ipdev_open_ifcfg(pif):
@@ -461,7 +461,7 @@  def action_up(pif, force):
         os.system(root_prefix() + "/sbin/update-issue")
 
         f.commit()
-    except Error, e:
+    except Error as e:
         log("failed to apply changes: %s" % e.msg)
         f.revert()
         raise
@@ -575,7 +575,7 @@  def action_force_rewrite(bridge, config):
     try:
         f.apply()
         f.commit()
-    except Error, e:
+    except Error as e:
         log("failed to apply changes: %s" % e.msg)
         f.revert()
         raise
@@ -606,7 +606,7 @@  def main(argv=None):
                         "no-syslog",
                         "help" ]
             arglist, args = getopt.gnu_getopt(argv[1:], shortops, longops)
-        except getopt.GetoptError, msg:
+        except getopt.GetoptError as msg:
             raise Usage(msg)
 
         force_rewrite_config = {}
@@ -713,11 +713,11 @@  def main(argv=None):
             # Save cache.
             db().save(dbcache_file)
 
-    except Usage, err:
+    except Usage as err:
         print >>sys.stderr, err.msg
         print >>sys.stderr, "For help use --help."
         return 2
-    except Error, err:
+    except Error as err:
         log(err.msg)
         return 1