Client Update Script

Is there a way to run a script on a client when an update is requested? Specifically I need to run it before the update takes place.

I’ve got a logging script on the client which writes certain values to a file on the client computer. This works fine and the log files roll over as expected at first.

The problem is that when I update the project it never closes the file handle on the original one and opens a new one. This is effectively seamless - we’re not writing to the old file handle anymore but are writing to the new one so logging still works. Until I go to roll over the file to a new one which involves os.rename() (pylib/logging/ line 346).

Normally this is OK since it closes the file stream before it does the rename. But since the old version is still open from the update it doesn’t work.

So I need some kind of cleanup logic to run when the project is updated on the client that makes sure the file handle is closed before starting again.

P.S. We’re using 8.1.0

system.util.getGlobals allows you to cache arbitrary objects for the lifetime of a given JVM (client, designer, gateway). Put the file handle into the dictionary at a well known key. In your script, check if the key exists and either resume using it, or close and re-open it accordingly.

Also, I’d recommend upgrading from 8.1.0 as soon as possible. There’s a lot of performance improvements and major bugfixes between that and latest 8.1.0.