Reading files from symbolic link folder

I have a symbolic link folder on the C drive of the machine running the gateway.
When I try:

os.path.exists(path)

it returns False.

When I try the same with a different folder on the C drive with the same permissions, it returns True.
Both folders appear when I try:

os.listdir('C:\\')

Any ideas why the gateway script cannot see the first folder?

try

os.path.islink(path)

this will return true if its a link even if it has no permissions or something

That also returns False.
The docs to mention that for os.path.islink(), it:

Always returns False if symbolic links are not supported by the Python runtime

I don't know if that is the case here.

Seems python 2.7 doesnt suppport symlinks on windows

hmm how about the igntions function? does that find it?

system.file.fileExists

Also no luck. Return False.

hmm you can try going java…

import java.io.File as File
path = "C:\\"
File(path).exists()

I don’t think it is an issue of python vs java.
Might be some Ignition conf setting need to change. Or maybe Ignition doesn’t like symbolic link folders.

maybe...

i was able to do both java and pyhton exists on a new junction symlink i made.
islink did not work tho

Use java’s File. It IS an issue of java vs. python. (Always use java’s alternatives to python’s stdlib in jython if you want predictable, bug-free operation.)

4 Likes

The Java version also did not work.

However it turned out it was a permissions thing in the end. Ignition is a system account user by default, and the system account user had no permission to read/write the mapped drive. And so neither the symbolic folder.
Followed this answer and changed Ignition login to be local user. All works now.

2 Likes