System.file.write error

I had the following error while writing a file to a drive on the Gateway Server, through a script called by a Gateway Timer. This is the first time we’ve seen this error, although the system is young. It left an empty file in the folder which caused quite a bit of grief. Any ideas what could have gone wrong? What can I do to ensure that the file is written correctly? My first thought is to encapsulate the file write in a try…except, and if the exception comes up, delete the file if it exists and try again on the next timer scan. Would this work. Is there a more full-proof and sophisticated solution?

7:35:05 AM


Error executing global timer script: tmrMain @250ms . Repeat errors of this type will be logged as ‘debug’ messages.

Traceback (most recent call last):
File “<TimerScript:IFI_12430_StackingCell/tmrMain @250ms >”, line 5, in
File “module:Robot”, line 157, in WriteFile
IOError: File ‘\\StackingPoints\PartData.txt’ doesn’t exist or isn’t a file.

at org.python.core.PyException.fillInStackTrace(
at java.lang.Throwable.<init>(
at java.lang.Exception.<init>(Unknown Source)
at java.lang.RuntimeException.<init>(Unknown Source)
at org.python.core.PyException.<init>(
at org.python.core.PyException.<init>(
at org.python.core.PyException.<init>(
at org.python.core.Py.IOError(
at com.inductiveautomation.ignition.common.script.builtin.FileUtilities.writeFile(
at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(
at org.python.core.PyReflectedFunction.__call__(
at org.python.core.PyObject.__call__(
at org.python.core.PyObject.__call__(
at org.python.pycode._pyx22.WriteFile$1(<module:Robot>:180)
at org.python.pycode._pyx22.call_function(<module:Robot>)
at org.python.core.PyFunction.__call__(
at org.python.pycode._pyx5.f$0(<TimerScript:IFI_12430_StackingCell/tmrMain @250ms >:8)
at org.python.pycode._pyx5.call_function(<TimerScript:IFI_12430_StackingCell/tmrMain @250ms >)
at org.python.core.Py.runCode(
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(
at java.util.TimerThread.mainLoop(Unknown Source)
at Source)

In that case you should be able to wrap it in a try…except block and delete the file if it throws an exception. It must be some sort of network blip when writing to the file.

The fact that an empty file was written has me confused. The trigger that the robot is looking for is that the file exists, so I’ll have to do something on that end to capture it as well. The location of the file is on the same computer as the gateway. Would it be better to write to D:\Folder instead of \IP\FolderShare?

Yes absolutely.