Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gf logic temporary file permission issue on windows #340

Open
antzware opened this issue Jun 23, 2020 · 1 comment
Open

gf logic temporary file permission issue on windows #340

antzware opened this issue Jun 23, 2020 · 1 comment
Labels

Comments

@antzware
Copy link

There seems to be a problem with the temporary file created with tempfile.NamedTemporaryFile in greatfet_logic.py as during the zip processing there will be a permission error like below
File "c:\users\mozor\appdata\local\programs\python\python38\lib\zipfile.py", line 1775, in write
with open(filename, "rb") as src, self.open(zinfo, 'w') as dest:
PermissionError: [Errno 13] Permission denied: 'D:\Work\tmpuxen_7_e'

The command prompt used is ran as administrator, there is no read only or write permissions issues on the Work folder. There are many users on the web that have issues with the handling of temporary file through that library with different proposed solutions.
A quick patch that worked for me was to replace the temporary file creation with
#bin_file = tempfile.NamedTemporaryFile(mode='w+b', suffix=".zip", dir=holding_dir)
bin_file = open(holding_dir + "\temp.zip", 'w+b')
of course the file is not temporary anymore but manually creating the file like this won't issue any permission errors.

@BJamin99
Copy link

I ran into this issue too. As per Python documentation for NamedTemporaryFile (https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile):

Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later)

Not sure if there is a benefit to using NamedTemporaryFile this way, but I've modified the code as such:

271 bin_file = tempfile.NamedTemporaryFile(dir=holding_dir, delete=False)

Then instead of doing a bin_file.flush(), I've modified it as such:

335 bin_file.close()

Finally cleanup after emitting the sigrok file by adding:

343 os.remove(bin_file_name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants