Os.remove os.unlink

Since 9 days, I have an error with this line:
os.unlink(path+’/’+fname)

Tag Diagnotics says :
OSError: unlink(): an unknown error occured D:\UTWIN-02-10-21-LOG.txt

But it worked for months. I don’t understand.

Phillippe,

I have a similar issue…

I’m attempting the removal of a directory with rmtree on a mapped drive.

The Zulu Java Platform releases the object lock only part of the time, but periodically it does not…and this causes the problem. If some time (several minutes) is allowed to pass, the lock seems to release the link on the object in question…and the object can be deleted. It is not consistent…works for a while, then doesn’t. …possibly an issue with garbage collection??

I’ve chased this issue with SysInternals Process Explorer…I can find the process locks that are connected to the objects that are causing issue. Deleting the process locks to the specific objects allows the deletion of the tree, but for some reason the process locks aren’t always detected in Process Explorer.

…and it doesn’t facilitate the expected normal operation of the system.

Did you find a resolution to the posted issue?

Many Thanks,
Jim

Use java’s java.io.File functionality instead of jython’s standard library.

Can we have more details on how to use the java.io.File functionality in a script?
We have a need to automate that process from a gateway timer script

Thanks

@xpouzet

There are a lot of ways to use that Class. Here is an example of how to check to see if a file exists:

from java.io import File
someFile =  File("C:\\PathMember1\\Pathmember2\\FileName.txt")
if someFile.exists():
	print "True"
else:
	print "False"

Just remember to escape your backslashes when setting you path, and it will work.

Here is a list of all of the methods for java.io.File that includes descriptions of how they are used: docs@Oracle:File