I would like to use a gateway scheduled event to look for changes in a db. The scheduled event will run code every minute. When I see a change I would like to use scripts that I have in the Project Library scripts section. I would like to call those scripts from the gateway event script because I have already written all the scripts that work with the DB and the PLC. I cannot figure out how to call them or if it is even possible.
Also, is this the best way to look for a change in a DB?
Pictures are great for context but please also post copies of code as preformatted text. It helps to speed up the troubleshooting process by others, see Wiki - how to post code on this forum. You can edit your post to add it via the pencil icon in the bottom right.
Please also post the full error stack trace (if one exists) as preformatted text as well, the full trace will have important information to help troubleshoot.
Based on your existing logic and logging, I'd say the failure is somewhere in your mainScript function, likely in one of the other functions that you are calling. If you are touching a DB, you are likely getting a java db error which won't be caught as a python Exception.
Add
except java.lang.Throwable as t:
logger.warn("A java exception occured", t)
to your try block, this should catch any java errors.
Additionally, I would avoid having import traceback that late in the script (or in a function at all). Move the gateway script logic to a project library script and call it with a single line from the scheduled script. Import traceback at the top of the project library script outside of the function.
Thanks for the information. And I will add the exception code.
I found the error to be cause by using system.perspective.print() statements in my other code, and maybe that is why it was fine when I called it in a perspective View but not a gateway script.