xzos / PyZDDE

Zemax/ OpticStudio Extension using Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"IOError: [Errno 13] Permission denied" for accessing analysis text files outputted by Zemax

indranilsinharoy opened this issue · comments

It is probably not a bug in PyZDDE as such. Also, this error happens rarely (not always, and very hard to reproduce) when some of the functions such as zGetPOP() request Zemax to export an analysis data as text file, and then the function tries to open the text file (in read mode), but is unable to do so because of file access denial. The error message is as follows (when it happens):

File " ...\PyZDDE\pyzdde\zdde.py", line 7022, in zGetPOP
    line_list = _readLinesFromFile(_openFile(textFileName))
File "C: \...\PyZDDE\pyzdde\zdde.py", line 10657, in _openFi1e
    f = open(fileName, 'r')
IOError: [Errno 13] Permission denied: 'C:\...\popData.txt'

Interestingly, when this error happens, the file outputted by Zemax doesn't show any owner. Instead it shows "Unable to display current owner". In normal cases, the owner of such files is usually the current user.

Also, when I execute icacls popData.txt from the command prompt in the directory containing the file, to display the discretionary access control lists (DACLs) on the file, I get

popData.txt: Access is denied.
Successfully processed 0 files; Failed processing 1 files

This issue could also cause problems (doesn't seem to happen always) to functions like ipzGetTextWindow(), zGetImageSimulation(), zGetMTF(), zGetPSF(), zGetPSFCrossSec(), zGetPOP(), etc.