From 62c8e45d49ddfdf67259a0ea48a891cc25c270b4 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Thu, 26 Jun 2014 09:58:34 +0900 Subject: [PATCH] python3: 2to3 tool Fixes for Python 3 with 2to3 partial https://github.com/vmware/pyvmomi/issues/55 --- pyVim/connect.py | 10 +++++----- pyVmomi/DynamicTypeManagerHelper.py | 4 ++-- pyVmomi/Iso8601.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pyVim/connect.py b/pyVim/connect.py index 5105d0a9c..e468572a9 100644 --- a/pyVim/connect.py +++ b/pyVim/connect.py @@ -227,7 +227,7 @@ def Connect(host='localhost', port=443, user='root', pwd='', host = info.group(1)[1:-1] if info.group(2) is not None: port = int(info.group(2)[1:]) - except ValueError, ve: + except ValueError as ve: pass if namespace: @@ -256,7 +256,7 @@ def Disconnect(si): def GetLocalTicket(si, user): try: sessionManager = si.content.sessionManager - except Exception, e: + except Exception as e: if type(e).__name__ == 'ExpatError': msg = 'Malformed response while querying for local ticket: "%s"' % e raise vim.fault.HostConnectFault(msg=msg) @@ -334,7 +334,7 @@ def __Login(host, port, user, pwd, service, adapter, version, path, x = content.sessionManager.Login(user, pwd, None) except vim.fault.InvalidLogin: raise - except Exception, e: + except Exception as e: raise return si, stub @@ -350,7 +350,7 @@ def __Logout(si): if si: content = si.RetrieveContent() content.sessionManager.Logout() - except Exception, e: + except Exception as e: pass @@ -473,7 +473,7 @@ def __VersionIsSupported(desiredVersion, serviceVersionDescription): root = serviceVersionDescription.getroot() if root.tag == 'namespaces': # serviceVersionDescription appears to be a vimServiceVersions.xml document - if root.get('version') <> '1.0': + if root.get('version') != '1.0': raise RuntimeError('vimServiceVersions.xml has version %s,' \ ' which is not understood' % (root.get('version'))) desiredVersionId = versionIdMap[desiredVersion] diff --git a/pyVmomi/DynamicTypeManagerHelper.py b/pyVmomi/DynamicTypeManagerHelper.py index dbd35590d..459da9536 100644 --- a/pyVmomi/DynamicTypeManagerHelper.py +++ b/pyVmomi/DynamicTypeManagerHelper.py @@ -45,7 +45,7 @@ def GetTypeManager(self): if self.hostSystem: try: dynTypeMgr = self.hostSystem.RetrieveDynamicTypeManager() - except vmodl.fault.MethodNotFound, err: + except vmodl.fault.MethodNotFound as err: pass if not dynTypeMgr: @@ -139,7 +139,7 @@ def _CreateAllTypes(self, enumTypes, dataTypes, managedTypes): for typeInfo in infos: try: fn(*typeInfo) - except Exception, err: + except Exception as err: #Ignore errors due to duplicate importing pass diff --git a/pyVmomi/Iso8601.py b/pyVmomi/Iso8601.py index c66ef7d5e..367a2a0ad 100644 --- a/pyVmomi/Iso8601.py +++ b/pyVmomi/Iso8601.py @@ -176,7 +176,7 @@ def ParseISO8601(datetimeStr): datetimeVal = datetime(**dt) if delta: datetimeVal += delta - except Exception, e: + except Exception as e: pass return datetimeVal