Hi, I have a problem with a script. I always get the same error with the last defined variable, as shown below.
//error
Traceback (most recent call last):
File “event:actionPerformed”, line 25, in
File “C:\Users\adria.ignition\cache\gwlocalhost_8088_8043_main\C1\pylib\encodings\utf_8.py”, line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: ‘utf-8’ codec can’t decode bytes in position 10-12: invalid data
//code
import time
import java
from java.io import File
from java.lang import *
pdf=event.source.parent.getComponent(‘pdf’).text
archivo = open(pdf, “rb”)
data = archivo.read()
if len(event.source.parent.parent.getComponent(‘incidencia’).text) <1:
event.source.parent.getComponent(‘asterisco’).visible=1
event.source.parent.getComponent(‘errorRojo’).visible=1
else:
event.source.parent.getComponent(‘asterisco’).visible=0
event.source.parent.getComponent(‘errorRojo’).visible=0
incidencia=event.source.parent.parent.getComponent(‘incidencia’).text
t_error=event.source.parent.getComponent(‘error’).selectedStringValue
f_inicio=event.source.parent.getComponent(‘f_inicio’).formattedDate
observaciones=event.source.parent.getComponent(‘observaciones’).text
f_sistema=time.strftime("%d/%m/%y %H:%M:%S")
event.source.parent.getComponent(‘observaciones’).text=""
event.source.parent.getComponent(‘pdf’).text=""
event.source.parent.parent.getComponent(‘incidencia’).text=""
DNI=event.source.parent.parent.DNI
query=“INSERT INTO incidencias (tipo_error, tipo_incidencia, observaciones,f_inicio, f_sistema, dni_operario, solucionado, doc_pdf) VALUES (’%s’,’%s’,’%s’,’%s’,’%s’,’%s’,’%s’,’%s’)” %(t_error, incidencia, observaciones, f_inicio, f_sistema,DNI ,“No”,data)
results=system.db.runPrepUpdate(query,[],‘DB’)
archivo.close()