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

ContentAccessDenied Error in ApiTestCase #187

Open
js-moreno opened this issue Sep 16, 2021 · 0 comments
Open

ContentAccessDenied Error in ApiTestCase #187

js-moreno opened this issue Sep 16, 2021 · 0 comments

Comments

@js-moreno
Copy link

js-moreno commented Sep 16, 2021

Hi,

I'm using this library and it works perfectly in production, but when I run a test for a view with PDFTemplateResponse, I get a ContentAccessDenied error.

I have use --load-error-handling: ignore and --quite:False, but it still doesn't work. Even the library tests show same error.

Specifications:

  • windows 10
  • python 3.8.3
  • django 3.0.10
  • djangorestframewor 3.11.3
  • django-wkhtmltopdf 3.3.0

Error:

Error: Failed to load file:///C:/Users/HP/AppData/Local/Temp/wkhtmltopdfsrv3uq3_.html, with network status code 201 and http status code 0 - Error opening C:/Users/HP/AppData/Local/Temp/wkhtmltopdfsrv3uq3_.html: El proceso no tiene acceso al archivo porque estß siendo utilizado por otro proceso.
Error: Failed loading page file:///C:/Users/HP/AppData/Local/Temp/wkhtmltopdfsrv3uq3_.html (sometimes it will work just to ignore this error with --load-error-handling ignore) 
Error: Failed to load http://true/, with network status code 3 and http status code 0 - Host true not found
Error: Failed loading page http://true (sometimes it will work just to ignore this error with --load-error-handling ignore)
Exit with code 1 due to network error: ContentAccessDenied
Internal Server Error: /quotes/d2388a94-702c-421d-983d-8629cb404e73/download/
Traceback (most recent call last):
  File "D:\projects\django\pack-server\.venv\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "D:\projects\django\pack-server\.venv\lib\site-packages\django\core\handlers\base.py", line 145, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "D:\projects\django\pack-server\.venv\lib\site-packages\django\core\handlers\base.py", line 143, in _get_response
    response = response.render()
  File "D:\projects\django\pack-server\.venv\lib\site-packages\django\template\response.py", line 105, in render
    self.content = self.rendered_content
  File "D:\projects\django\pack-server\.venv\lib\site-packages\wkhtmltopdf\views.py", line 73, in rendered_content
    return render_pdf_from_template(
  File "D:\projects\django\pack-server\.venv\lib\site-packages\wkhtmltopdf\utils.py", line 232, in render_pdf_from_template
    return convert_to_pdf(filename=input_file.filename,
  File "D:\projects\django\pack-server\.venv\lib\site-packages\wkhtmltopdf\utils.py", line 165, in convert_to_pdf
    return wkhtmltopdf(pages=pages, **cmd_options)
  File "D:\projects\django\pack-server\.venv\lib\site-packages\wkhtmltopdf\utils.py", line 146, in wkhtmltopdf
    return check_output(ck_args, **ck_kwargs)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 470, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, **kwargs).stdout
  File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 567, in run
    raise CalledProcessError(retcode, process.args, output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['C:/Program', 'Files/wkhtmltopdf/bin/wkhtmltopdf', '--dpi', '300', '--enable-local-file-access', '--encoding', 'utf8', '--margin-bottom', '25', '--margin-left', '2', '--margin-right', '2', '--margin-top', '25', '--page-size', 'A4', '--print-media-type',  'C:\\Users\\HP\\AppData\\Local\\Temp\\wkhtmltopdfsrv3uq3_.html', '-']' returned non-zero exit status 1.

I appreciate your help

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

1 participant