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

Permission denied when writing tempfile on windows #14

Open
martinvilu opened this issue Sep 21, 2018 · 1 comment
Open

Permission denied when writing tempfile on windows #14

martinvilu opened this issue Sep 21, 2018 · 1 comment

Comments

@martinvilu
Copy link

It doesn't work out of the box because of the tempfile.NamedTemporaryFile used on file_utils returns an open file, not just the name, which can't be reopened.

Note

Closing the file returned by the function get_tempfile works because the handle is never used. Not pretty, but works.

(template.py/SVGDocument.render and template.py/LateXDocument.render)

Traceback:

C:\Users\Martin\1-CAREM\3-Caratulas Manuales>docstamp create -v -i data.csv -t caratula-tmpl_2.svg -d svg -o caratulas
DEBUG:docstamp.cli.cli:Reading CSV elements from C:\Users\Martin\1-CAREM\3-Caratulas Manuales\data.csv.
DEBUG:docstamp.cli.cli:Creating the template object using the file C:\Users\Martin\1-CAREM\3-Caratulas Manuales\caratula-tmpl_2.svg.
DEBUG:docstamp.cli.cli:Created an object of type <class 'docstamp.template.SVGDocument'>.
DEBUG:docstamp.cli.cli:Filling template 00 with values of item 0.
DEBUG:docstamp.cli.cli:Rendering file C:\Users\Martin\1-CAREM\3-Caratulas Manuales\caratulas\caratula-tmpl_2_00.svg.
C:\Users\Martin\AppData\Local\Temp\tmpsa4be55x.svg
ERROR:docstamp.file_utils:Error writing to file in C:\Users\Martin\AppData\Local\Temp\tmpsa4be55x.svg
Traceback (most recent call last):
  File "C:\Users\Martin\1-CAREM\3-Caratulas Manuales\python\python-3.7.0\lib\site-packages\docstamp\file_utils.py", line 192, in write_to_file
    with open(file_path, "wb") as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Martin\\AppData\\Local\\Temp\\tmpsa4be55x.svg'
ERROR:docstamp.template:Document of type <class 'docstamp.template.SVGDocument'> got an error when                    writing content.
Traceback (most recent call last):
  File "C:\Users\Martin\1-CAREM\3-Caratulas Manuales\python\python-3.7.0\lib\site-packages\docstamp\template.py", line 158, in save_content
    encoding=encoding)
  File "C:\Users\Martin\1-CAREM\3-Caratulas Manuales\python\python-3.7.0\lib\site-packages\docstamp\file_utils.py", line 192, in write_to_file
    with open(file_path, "wb") as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Martin\\AppData\\Local\\Temp\\tmpsa4be55x.svg'
ERROR:docstamp.cli.cli:Error creating C:\Users\Martin\1-CAREM\3-Caratulas Manuales\caratulas\caratula-tmpl_2_00.svg for {'numero': '1', 'zzBibliorato': '1', 'rack': 'IUS', 'tomo': 'Tomo único', 'copia': '1', 'Entrega': '
1', 'codigo': '100271', 'contenido': 'IUS-1001|IUS-1002|||||', 'contenido_1': 'IUS-1001', 'contenido_2': 'IUS-1002', 'contenido_3': '', 'contenido_4': '', 'contenido_5': '', 'contenido_6': '', 'contenido_7': '', 'columna
_inventariado': 'SCMP - Diagramas eléctricos y Layout IUS: Bibliorato 1 Copia 1 (Entrega 1) IUS Tomo único (IUS-1001)'}.
Traceback (most recent call last):
  File "C:\Users\Martin\1-CAREM\3-Caratulas Manuales\python\python-3.7.0\lib\site-packages\docstamp\template.py", line 158, in save_content
    encoding=encoding)
  File "C:\Users\Martin\1-CAREM\3-Caratulas Manuales\python\python-3.7.0\lib\site-packages\docstamp\file_utils.py", line 192, in write_to_file
    with open(file_path, "wb") as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Martin\\AppData\\Local\\Temp\\tmpsa4be55x.svg'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Martin\1-CAREM\3-Caratulas Manuales\python\python-3.7.0\lib\site-packages\docstamp\cli\cli.py", line 154, in create
    template_doc.render(file_path, **kwargs)
  File "C:\Users\Martin\1-CAREM\3-Caratulas Manuales\python\python-3.7.0\lib\site-packages\docstamp\template.py", line 248, in render
    self.save_content(temp.name)
  File "C:\Users\Martin\1-CAREM\3-Caratulas Manuales\python\python-3.7.0\lib\site-packages\docstamp\template.py", line 163, in save_content
    raise Exception(msg) from exc
Exception: Document of type <class 'docstamp.template.SVGDocument'> got an error when                    writing content.
@alexsavio
Copy link
Member

Thanks for the bug report!

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

No branches or pull requests

2 participants