PDF error print

86 views
Skip to first unread message

Pedro Argolo Piedade

unread,
May 14, 2025, 10:01:27 AMMay 14
to QATrack+
Hi Yall, I have just upgrade my qatrack to branch 3.1.1.4 in a new VM.
I have installed Ubuntu 24.04.2 LTS, with python 3.9.22 and pylinac 3.33.0.

I am trying to gets some pdf reports in PDF mode thruoth the review area for a specifit test list, but it´s not working Error 500 : Server Error

I went to the folder \\192.168.10.11\qatrack\web\qatrackplus\qatrack\media\reports did not find the pdf and the logs \\192.168.10.11\qatrack\web\qatrackplus\logs show no error.

In the folder reports i saw some hmtl that looks like is the file to convert into pdf, but is all strange without any format.
Just to register my pip list in VENV

(qatrack31) qatrack@qatrack-server:~$ pip list
Package                     Version        Editable project location
--------------------------- -------------- --------------------------------------------------------
annotated-types             0.7.0
argue                       0.3.1
arrow                       1.3.0
attrs                       25.3.0
beautifulsoup4              4.9.3
black                       23.1.0
blessed                     1.21.0
certifi                     2025.4.26
cffi                        1.17.1
chardet                     5.2.0
click                       8.1.8
concurrent-log-handler      0.9.19
confusable-homoglyphs       3.3.1
contourpy                   1.3.0
coreapi                     2.3.3
coreschema                  0.0.4
coverage                    5.4
cryptography                3.4.8
cssutils                    2.11.1
cycler                      0.12.1
Django                      2.2.18
django-admin-views          0.8.0
django-auth-adfs            1.6.0
django-braces               1.13.0
django-contrib-comments     1.8.0
django-coverage             1.2.4
django-crispy-forms         1.6.0
django-debug-toolbar        2.0
django-dynamic-raw-id       2.8
django-extensions           3.1.0
django-filter               2.4.0
django-form-utils           1.0.3
django-formtools            2.1
django-genericdropdown      0.1            /home/qatrack/venvs/qatrack31/src/django-genericdropdown
django-js-asset             2.0.0
django-listable             0.5.2
django-mptt                 0.10.0
django-mptt-admin           0.7.2
django-picklefield          2.0
django-q                    1.3.4
django-recurrence           1.10.1         /home/qatrack/venvs/qatrack31/src/django-recurrence
django-registration         3.1.1
django-sql-explorer         2.1.2          /home/qatrack/venvs/qatrack31/src/django-sql-explorer
django-widget-tweaks        1.4.1
djangorestframework         3.12.2
djangorestframework-filters 1.0.0.dev0
dnspython                   2.7.0
EasyProcess                 1.1
email_validator             2.2.0
et_xmlfile                  2.0.0
eval_type_backport          0.2.2
fonttools                   4.57.0
freezegun                   0.3.15
future                      0.18.3
html5lib                    1.1
idna                        3.10
imageio                     2.37.0
importlib_resources         6.5.2
iniconfig                   2.1.0
itypes                      1.2.0
jdcal                       1.4.1
Jinja2                      3.1.6
kiwisolver                  1.4.7
lazy_loader                 0.4
Markdown                    3.3.3
MarkupSafe                  3.0.2
matplotlib                  3.9.4
mod_wsgi                    5.0.2
more-itertools              10.7.0
mypy_extensions             1.1.0
narwhals                    1.36.0
networkx                    3.2.1
numpy                       1.26.4
openpyxl                    3.0.6
packaging                   25.0
pandas                      1.1.5
pathspec                    0.12.1
pep8                        1.7.1
pillow                      11.2.1
pip                         25.1
platformdirs                4.3.7
plotly                      6.0.1
pluggy                      1.0.0.dev0
portalocker                 3.1.1
psycopg2-binary             2.8.6
py                          1.11.0
py-linq                     1.4.0
pycparser                   2.22
pydantic                    2.11.3
pydantic_core               2.33.1
pydicom                     2.4.4
PyJWT                       2.10.1
pylinac                     3.33.0
pynliner                    0.8.0
pyparsing                   3.2.3
pytest                      6.2.2
pytest-cov                  2.11.1
pytest-django               4.1.0
pytest-sugar                0.9.4
python-dateutil             2.9.0.post0
pytz                        2021.1
PyVirtualDisplay            2.0
PyWavelets                  1.4.1
PyYAML                      6.0.2
quaac                       1.0.2
reportlab                   4.4.0
requests                    2.21.0
scikit-image                0.24.0
scipy                       1.13.1
selenium                    3.141.0
setuptools                  58.1.0
six                         1.17.0
soupsieve                   2.7
sqlparse                    0.5.3
tabulate                    0.9.0
termcolor                   3.0.1
tifffile                    2024.8.30
toml                        0.10.2
tomli                       2.2.1
tqdm                        4.67.1
types-python-dateutil       2.9.0.20241206
typing_extensions           4.13.2
typing-inspection           0.4.0
uritemplate                 4.1.1
urllib3                     1.24.3
wcwidth                     0.2.13
webencodings                0.5.1
xlrd                        2.0.1
XlsxWriter                  1.3.7
zipp                        3.21.0
(qatrack31) qatrack@qatrack-server:~$ python --version
Python 3.9.22

My best regards

Pedro P

Pedro Argolo Piedade

unread,
May 14, 2025, 10:17:43 AMMay 14
to QATrack+
Reading other question I did some test without any success.

Tested if Chrome is installed.
qatrack@qatrack-server:/var/log/apache2$ which google-chrome
/usr/bin/google-chrome
qatrack@qatrack-server:/var/log/apache2$ which chromium-browser
qatrack@qatrack-server:/var/log/apache2$ google-chrome --version
Google Chrome 135.0.7049.114
qatrack@qatrack-server:/var/log/apache2$


I did the permission 

sudo chown -R www-data:www-data /home/qatrack/web/qatrackplus/qatrack/{media,static,cache}
sudo chmod -R ug+rwxs /home/qatrack/web/qatrackplus/qatrack/{media,static,cache}

looked /var/log/apache2/error.log

[Wed May 14 09:55:23.600709 2025] [wsgi:error] [pid 2316313:tid 139342657824448]                                                                                                                                                              [remote 192.168.10.112:57529]   File "/home/qatrack/web/qatrackplus/qatrack/qa/                                                                                                                                                             views/review.py", line 93, in test_list_instance_report
[Wed May 14 09:55:23.600713 2025] [wsgi:error] [pid 2316313:tid 139342657824448]                                                                                                                                                              [remote 192.168.10.112:57529]     return report.render_to_response(base_opts['r                                                                                                                                                             eport_format'])
[Wed May 14 09:55:23.600720 2025] [wsgi:error] [pid 2316313:tid 139342657824448]                                                                                                                                                              [remote 192.168.10.112:57529]   File "/home/qatrack/web/qatrackplus/qatrack/rep                                                                                                                                                             orts/reports.py", line 131, in render_to_response
[Wed May 14 09:55:23.600725 2025] [wsgi:error] [pid 2316313:tid 139342657824448]                                                                                                                                                              [remote 192.168.10.112:57529]     fname, content = self.render(report_format)
[Wed May 14 09:55:23.600730 2025] [wsgi:error] [pid 2316313:tid 139342657824448]                                                                                                                                                              [remote 192.168.10.112:57529]   File "/home/qatrack/web/qatrackplus/qatrack/rep                                                                                                                                                             orts/reports.py", line 122, in render
[Wed May 14 09:55:23.600734 2025] [wsgi:error] [pid 2316313:tid 139342657824448]                                                                                                                                                              [remote 192.168.10.112:57529]     content = getattr(self, "to_%s" % report_form                                                                                                                                                             at)()
[Wed May 14 09:55:23.600739 2025] [wsgi:error] [pid 2316313:tid 139342657824448]                                                                                                                                                              [remote 192.168.10.112:57529]   File "/home/qatrack/web/qatrackplus/qatrack/rep                                                                                                                                                             orts/reports.py", line 263, in to_pdf
[Wed May 14 09:55:23.600743 2025] [wsgi:error] [pid 2316313:tid 139342657824448]                                                                                                                                                              [remote 192.168.10.112:57529]     return chrometopdf(content, name=fname)
[Wed May 14 09:55:23.600748 2025] [wsgi:error] [pid 2316313:tid 139342657824448]                                                                                                                                                              [remote 192.168.10.112:57529]   File "/home/qatrack/web/qatrackplus/qatrack/qat                                                                                                                                                             rack_core/utils.py", line 52, in chrometopdf
[Wed May 14 09:55:23.600752 2025] [wsgi:error] [pid 2316313:tid 139342657824448]                                                                                                                                                              [remote 192.168.10.112:57529]     if not out_file.closed:
[Wed May 14 09:55:23.600757 2025] [wsgi:error] [pid 2316313:tid 139342657824448]                                                                                                                                                              [remote 192.168.10.112:57529] UnboundLocalError: local variable 'out_file' refe                                                                                                                                                             renced before assignment

I set `DEBUG = True` in local_settings.py

UnboundLocalError at /qc/session/details/1784/report/
local variable 'out_file' referenced before assignment
Request Method: GET
Request URL: http://192.168.10.11/qc/session/details/1784/report/?type=pdf
Django Version: 2.2.18
Exception Type: UnboundLocalError
Exception Value:
local variable 'out_file' referenced before assignment
Exception Location: /home/qatrack/web/qatrackplus/qatrack/qatrack_core/utils.py in chrometopdf, line 52
Python Executable: /home/qatrack/venvs/qatrack31/bin/python
Python Version: 3.9.22
Python Path:
['/home/qatrack/web/qatrackplus',
 '/usr/lib/python39.zip',
 '/usr/lib/python3.9',
 '/usr/lib/python3.9/lib-dynload',
 '/home/qatrack/venvs/qatrack31/lib/python3.9/site-packages']
Server time: Wed, 14 May 2025 10:09:51 -0400

Pedro Argolo Piedade

unread,
May 15, 2025, 2:01:37 PMMay 15
to QATrack+
I solve the error 500 in my VM to save pdf file. The problem was the Chromium instalation.

1-uninstall chromium 
sudo snap remove chromium

2- install 
sudo add-apt-repository ppa:saiarcot895/chromium-dev
sudo apt update
sudo apt install chromium-browser

also can check the version installed
which google-chrome, for linux should be  /usr/bin/google-chrome

I set in local_settings.py a new variable in the end of the file
CHROME_PATH = "/usr/bin/google-chrome"

3-restart apache2
sudo systemctl restart apache2

Happpy QA to yall!!!

Cody Crewson

unread,
May 22, 2025, 12:55:15 PMMay 22
to QATrack+
That's great to hear, we'll add it to the documentation as we go forward with updates
Reply all
Reply to author
Forward
0 new messages