I am trying to connect to vm using python. I need to do a server healthcheck report
I have written the below code to connect to the vm but getting error
svr = "test8ap"
import winrm
import getpass
from pysphere.vi_server import VIServer
try:
usrname = input("Enter Username: ")
passwd = getpass.getpass('Enter Password: ')
except Exception as err:
print('Error Occured : ', err)
def viConnect(vCenter,username,password,vmname):
server = pysphere.VIServer()
server.connect(vCenter,username,password)
return getVm(server,vmname)
conn = viConnect('12.68.18.1',usrname,passwd,svr)
error
C:\Users\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/PycharmProjects/pythonProject/venv/VM_Data.py
Traceback (most recent call last):
File "C:\Users\PycharmProjects\pythonProject\venv\VM_Data.py", line 4, in <module>
from pysphere.vi_server import VIServer
File "C:\Users\PycharmProjects\pythonProject\venv\lib\site-packages\pysphere\__init__.py", line 171, in <module>
from pysphere.vi_task import VITask
File "C:\Users\PycharmProjects\pythonProject\venv\lib\site-packages\pysphere\vi_task.py", line 110
except (VI.ZSI.FaultException), e:
^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized
Process finished with exit code 1
Can you please let me know what is the issue here.
Tried solution provided SyntaxError: multiple exception types must be parenthesized - comtypes
but still getting same error
CodePudding user response:
There seems to be a bug in the code of the module you are using. Is that your module? If not try reinstalling it and checking weather it is compatible with your current python Version!