Indigo Error Log script fails under Python 3

Posted on
Sat May 14, 2022 6:53 pm
Monstergerm offline
Posts: 274
Joined: Sep 01, 2009

Indigo Error Log script fails under Python 3

The following script no longer works under Python 3.
The error message is:
Indigo Error Log Script.py, line 6, at top level
File '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/encodings/ascii.py', line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 27870: ordinal not in range(128)

Script Error trigger "Indigo Event Log Error Email v2" script error in file Indigo Error Log Script.py:
Script Error 'ascii' codec can't decode byte 0xc3 in position 27870: ordinal not in range(128)
Script Error Exception Traceback (most recent call shown last):


This error repeats endlessly until I restart the Indigo Server. Any suggestions?

Code: Select all
logFilePath = indigo.server.getLogsFolderPath() + u"/indigo_log.txt"

check_list  = (' Err ', ' err ', 'Error', 'error')  # things to include
skip_list   = ('errorState :', "Indigo Error Log Report", "Reset errorsDetected")  # things to ignore
with open(logFilePath, "r") as infile:
   logFile = infile.read()

# Get line when it contains anything in the checklist and not anything in the skip list.
errorLines = [line for line in logFile.split('\n')
   if any(check in line for check in check_list)
   and not any(skip in line for skip in skip_list)]

errorLines = ("\n".join(errorLines)) # converts list object to line-by-line string object

myAddress = "name@spectrum.com"
mySubject = "Indigo Error Log Report"

indigo.server.sendEmailTo(myAddress, subject=mySubject, body=errorLines)

Posted on
Sun May 15, 2022 1:48 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Indigo Error Log script fails under Python 3

This is because of how Python stores strings as bytes.

There’s various options on http://python-notes.curiousefficiency.o ... ssing.html but the one that matches most the advice from Matt/Jay and the other devs is:

Code: Select all
f = open(fname, encoding="utf-8")


So try adding the encoding to your open() line.


Sent from my iPhone using Tapatalk Pro

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

Re: Indigo Error Log script fails under Python 3

[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 3 guests