Python error in reflector check code after update to 2022.1

Posted on
Sat May 14, 2022 5:12 pm
DVDDave offline
Posts: 470
Joined: Feb 26, 2006
Location: San Jose, CA

Python error in reflector check code after update to 2022.1

My update to 2022.1 (while still on OS 12.2) has mostly gone fine after slogging through some python errors. However, I can't seem to solve an error in a reflector check script that Matt helped me with a while ago. Here is the code:

Code: Select all
import urllib

query_url = 'http://YOUR_REFLEDCTOR_NAME_HERE.indigodomo.net/prismstatus'
try:
   result = urllib.urlopen(query_url, None)
   if result is not None:
      server_reply_str = result.read()
      if server_reply_str == 'connected':
         pass
         # Comment out or delete this next log line after verifying it is working:
         indigo.server.log('reflector test returned connected')
      else:
         indigo.server.log('reflector test returned ' + server_reply_str, isError=True)
   else:
      indigo.server.log('reflector test returned None', isError=True)
except IOError, e:
   indigo.server.log('reflector test error: ' + str(e), isError=True)


I get this error when executing it:
Code: Select all
   Action Group                    Reflector Check
   Script Error                    action group "Reflector Check" script error in file Reflector_Check.py:
   Script Error                    multiple exception types must be parenthesized
   Script Error                    around line 24 - "except IOError, e:"


Googling around, it looks like it has something to do with using a python2 library (comtypes) with python3 but I can't find a definitive solution. Any suggestions?

Thanks!

--Dave

Posted on
Sat May 14, 2022 6:02 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Python error in reflector check code after update to 202

Change this line:
Code: Select all
except IOError, e:
to this:
Code: Select all
except IOError as e:

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat May 14, 2022 8:15 pm
DVDDave offline
Posts: 470
Joined: Feb 26, 2006
Location: San Jose, CA

Re: Python error in reflector check code after update to 202

Thanks, Dave!

FYI, I also needed to change urllib to urllib.request.

Posted on
Sat May 14, 2022 8:41 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Python error in reflector check code after update to 202

Cool, glad you figured it out. I zeroed in on the exception. :)

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun May 15, 2022 10:53 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python error in reflector check code after update to 202

[MODERATOR NOTE]: moved to the Python 3 conversion forum.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests