eflomal
eflomal copied to clipboard
Re-opening open NamedTemporaryFile files won't work on Windows
I was hoping there was an aligner that actually worked on Windows, but unfortunately it doesn't. The first issue I bump into is the file handling.
On Windows you can't re-open NamedTemporaryFile
files that are open - it will give a Permission Denied error.
EDIT: I spoke before my turn. The issue seems more intricate than what I had assumed. Apologies. The issue remains, though.
Trace:
PS C:\tools\eflomal> python .\align.py -s .\source.txt -t .\target.txt
Traceback (most recent call last):
File ".\align.py", line 142, in <module>
if __name__ == '__main__': main()
File ".\align.py", line 136, in main
use_gdb=args.debug)
File "python\eflomal\eflomal.pyx", line 123, in eflomal.align
with open(source_filename, 'rb') as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\user\\AppData\\Local\\Temp\\tmphqbksy6m'
i am facing the same problem did you find a solution?
Alas, no. Did not get any feedback from authors.
Hi, sorry I missed this. Unfortunately I don't have a Windows system to test on, so I can't debug this on my own. If anyone comes up with a portable solution I would be happy to accept it as a pull request. An emergency measure would be to add an option that creates a temporary file in a less secure way. Would that be acceptable for your use case?
yes, I tried to add a specific location for the temp files but it did not work, please if you have any solution to specify the place it will be great. Many thanks
This is apparently a difference between Unix and Windows, Windows doesn't allow you to open a NamedTemporaryFile again. As a workaround, you can add "delete=False" to the NamedTemporaryFiles calls and close the files before align function is called. This does mean the temp files aren't deleted, so you'll also need to add temp file cleanup after the align call. I'm experimenting with eflomal for use with a Windows-based tool, so I might be able to make the necessary changes and add them to the codebase later.