Hello
Could you please help me with one issue? Since few days I can't delete certain files from Gateway directory by script (E:\Program Files\Inductive Automation\Ignition\webserver\webapps\main\someDirectory....). It used to work fine for few weeks, now I can see unlink OSError in the log.
I thought I will fix it based on past topics from this forum, but looks like I didn't found a root cause.
I was reviewing these topics:
looking for some help. Originally I was executing this code to save a picture using script:
...
import os
...
myFile = open(path, 'wb')
myFile.write(f.read())
myFile.close()
and then in another script I was deleting this file by:
os.remove(item)
Since few days I see this in a log:
Caused by: org.python.core.PyException: OSError: unlink(): an unknown error occurred: E:\Program Files\Inductive Automation\Ignition\webserver\webapps\main\RR_crates\PLD2\2024-01-25-09-38-16_12345678900987654_cam1.jpg
... 39 common frames omitted
Caused by: java.nio.file.AccessDeniedException: E:\Program Files\Inductive Automation\Ignition\webserver\webapps\main\RR_crates\PLD2\2024-01-25-09-38-16_12345678900987654_cam1.jpg
at java.base/sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source)
at java.base/sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(Unknown Source)
at java.base/java.nio.file.Files.deleteIfExists(Unknown Source)
at org.python.modules.posix.PosixModule.unlink(PosixModule.java:1119)
After reading topics mentioned above I thought migrating to java.io.File and java.nio.file.Files will fix it and it will work fine, but I get the same error as before ;(
Where should I look for a solution in a code?
Now I have this for saving:
myFile = File(path)
myPath = myFile.toPath()
Files.write(myPath, f.read())
and deleting:
pattern=rE:\ProgramFiles\InductiveAutomation\Ignition\webserver\webapps\main\RR_crates\PLD2\*.jpg
for item in glob.iglob(pattern):
someFile = File(item)
someFile.delete()
It works (deleting) only for files created from other source than Ignition. All files created using this script are blocked by java.exe when trying to delete it from Windows Explorer:
I assume same process blocks deletion when Ignition executes my script, but I don't know how avoid this scenario in a future.
I would be thankful for any suggestions, thank you, regards, Gregory
Let me know please what else I can paste here - this is my first post here:)
In using Ignition 8.1.36 version, recently updated, before we had 8.1.23 (as far as I remember).