python3: 2to3 tool
Fixes for Python 3 with 2to3 partial https://github.com/vmware/pyvmomi/issues/55
This commit is contained in:
parent
a8c1be6b7b
commit
170ea1dece
@ -222,7 +222,7 @@ def Connect(host='localhost', port=443, user='root', pwd='',
|
|||||||
host = info.group(1)[1:-1]
|
host = info.group(1)[1:-1]
|
||||||
if info.group(2) is not None:
|
if info.group(2) is not None:
|
||||||
port = int(info.group(2)[1:])
|
port = int(info.group(2)[1:])
|
||||||
except ValueError, ve:
|
except ValueError as ve:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if namespace:
|
if namespace:
|
||||||
@ -251,7 +251,7 @@ def Disconnect(si):
|
|||||||
def GetLocalTicket(si, user):
|
def GetLocalTicket(si, user):
|
||||||
try:
|
try:
|
||||||
sessionManager = si.content.sessionManager
|
sessionManager = si.content.sessionManager
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if type(e).__name__ == 'ExpatError':
|
if type(e).__name__ == 'ExpatError':
|
||||||
msg = 'Malformed response while querying for local ticket: "%s"' % e
|
msg = 'Malformed response while querying for local ticket: "%s"' % e
|
||||||
raise vim.fault.HostConnectFault(msg=msg)
|
raise vim.fault.HostConnectFault(msg=msg)
|
||||||
@ -329,7 +329,7 @@ def __Login(host, port, user, pwd, service, adapter, version, path,
|
|||||||
x = content.sessionManager.Login(user, pwd, None)
|
x = content.sessionManager.Login(user, pwd, None)
|
||||||
except vim.fault.InvalidLogin:
|
except vim.fault.InvalidLogin:
|
||||||
raise
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
raise
|
raise
|
||||||
return si, stub
|
return si, stub
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ def __Logout(si):
|
|||||||
if si:
|
if si:
|
||||||
content = si.RetrieveContent()
|
content = si.RetrieveContent()
|
||||||
content.sessionManager.Logout()
|
content.sessionManager.Logout()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@ -465,7 +465,7 @@ def __VersionIsSupported(desiredVersion, serviceVersionDescription):
|
|||||||
root = serviceVersionDescription
|
root = serviceVersionDescription
|
||||||
if root.tag == 'namespaces':
|
if root.tag == 'namespaces':
|
||||||
# serviceVersionDescription appears to be a vimServiceVersions.xml document
|
# 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,' \
|
raise RuntimeError('vimServiceVersions.xml has version %s,' \
|
||||||
' which is not understood' % (root.get('version')))
|
' which is not understood' % (root.get('version')))
|
||||||
desiredVersionId = versionIdMap[desiredVersion]
|
desiredVersionId = versionIdMap[desiredVersion]
|
||||||
|
@ -45,7 +45,7 @@ class DynamicTypeImporter:
|
|||||||
if self.hostSystem:
|
if self.hostSystem:
|
||||||
try:
|
try:
|
||||||
dynTypeMgr = self.hostSystem.RetrieveDynamicTypeManager()
|
dynTypeMgr = self.hostSystem.RetrieveDynamicTypeManager()
|
||||||
except vmodl.fault.MethodNotFound, err:
|
except vmodl.fault.MethodNotFound as err:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not dynTypeMgr:
|
if not dynTypeMgr:
|
||||||
@ -139,7 +139,7 @@ class DynamicTypeConstructor:
|
|||||||
for typeInfo in infos:
|
for typeInfo in infos:
|
||||||
try:
|
try:
|
||||||
fn(*typeInfo)
|
fn(*typeInfo)
|
||||||
except Exception, err:
|
except Exception as err:
|
||||||
#Ignore errors due to duplicate importing
|
#Ignore errors due to duplicate importing
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ def ParseISO8601(datetimeStr):
|
|||||||
datetimeVal = datetime(**dt)
|
datetimeVal = datetime(**dt)
|
||||||
if delta:
|
if delta:
|
||||||
datetimeVal += delta
|
datetimeVal += delta
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
return datetimeVal
|
return datetimeVal
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user