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

Reporter - Fails to generate docx, html and xlsx reports #144

Closed
pkievit-copado opened this issue Apr 24, 2023 · 4 comments
Closed

Reporter - Fails to generate docx, html and xlsx reports #144

pkievit-copado opened this issue Apr 24, 2023 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@pkievit-copado
Copy link

Describe the bug
Reporter - Fail to generate docx, html and xlsx reports

To Reproduce
Steps to reproduce the behavior:

rfswarm-reporter -n -i '/Users/patrick/Library/Application Support/Copado/QConnect/execution/performance-testing/files/configuration/RFSwarmReporter.ini' --debug 1 -d '/Users/patrick/Library/Application Support/Copado/QConnect/execution/performance-testing/20230424_105440_qconnect-load-test/20230424_105440_qconnect-load-test.db' -t '/Users/patrick/Library/Application Support/Copado/QConnect/execution/performance-testing/files/reporting/default.template' --html --xlsx --docx

Expected behavior
Reports formats should be generated.

Desktop (please complete the following information):

  • OS: Mac OS Ventura
  • Version version 1.1.0 latest using standalone_python version 3.9.7

Log

`rfswarm-reporter -n -i '/Users/patrick/Library/Application Support/Copado/QConnect/execution/performance-testing/files/configuration/RFSwarmReporter.ini' --debug 1 -d '/Users/patrick/Library/Application Support/Copado/QConnect/execution/performance-testing/20230424_105440_qconnect-load-test/20230424_105440_qconnect-load-test.db' -t '/Users/patrick/Library/Application Support/Copado/QConnect/execution/performance-testing/files/reporting/default.template' --html --xlsx --docx

Robot Framework Swarm: Reporter

Version 1.1.0 

self.args.ini: /Users/patrick/Library/Application Support/Copado/QConnect/execution/performance-testing/files/configuration/RFSwarmReporter.ini

Configuration File:  /Users/patrick/Library/Application Support/Copado/QConnect/execution/performance-testing/files/configuration/RFSwarmReporter.ini 

Generating XHTML Report

Generating Word Report

Exception in thread Thread-1:

Traceback (most recent call last):

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/threading.py", line 973, in _bootstrap_inner

Generating Excel Report

Exception in thread Thread-3:

Traceback (most recent call last):

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/threading.py", line 973, in _bootstrap_inner

self.run()

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/threading.py", line 910, in run

self._target(*self._args, **self._kwargs)

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/site-packages/rfswarm_reporter/rfswarm-reporter", line 2524, in export_xhtml

self.run()

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/threading.py", line 910, in run

fontname = base.rs_setting_get_font()

self._target(*self._args, **self._kwargs)

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/site-packages/rfswarm_reporter/rfswarm-reporter", line 2621, in export_excel

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/site-packages/rfswarm_reporter/rfswarm-reporter", line 533, in rs_setting_get_font

fontlst = list(tkFont.families())

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/tkinter/font.py", line 183, in families

root = tkinter._get_default_root('use font.families()')

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/tkinter/init.py", line 297, in _get_default_root

raise RuntimeError(f"Too early to {what}: no default root window")

RuntimeError: Too early to use font.families(): no default root window

self.xlsx_configure_style()

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/site-packages/rfswarm_reporter/rfswarm-reporter", line 3772, in xlsx_configure_style

fontname = base.rs_setting_get_font()

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/site-packages/rfswarm_reporter/rfswarm-reporter", line 533, in rs_setting_get_font

fontlst = list(tkFont.families())

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/tkinter/font.py", line 183, in families

root = tkinter._get_default_root('use font.families()')

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/tkinter/init.py", line 297, in _get_default_root

raise RuntimeError(f"Too early to {what}: no default root window")

RuntimeError: Too early to use font.families(): no default root window

Exception in thread Thread-2:

Traceback (most recent call last):

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/threading.py", line 973, in _bootstrap_inner

self.run()

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/threading.py", line 910, in run

self._target(*self._args, **self._kwargs)

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/site-packages/rfswarm_reporter/rfswarm-reporter", line 2585, in export_word

self.docx_configure_style()

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/site-packages/rfswarm_reporter/rfswarm-reporter", line 3158, in docx_configure_style

fontname = base.rs_setting_get_font()

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/site-packages/rfswarm_reporter/rfswarm-reporter", line 533, in rs_setting_get_font

fontlst = list(tkFont.families())

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/tkinter/font.py", line 183, in families

root = tkinter._get_default_root('use font.families()')

File "/Applications/QConnect.app/Contents/Resources/standalone_python/install/lib/python3.9/tkinter/init.py", line 297, in _get_default_root

raise RuntimeError(f"Too early to {what}: no default root window")

RuntimeError: Too early to use font.families(): no default root window

patrick@MacBook-Pro-van-Patrick ~ % `

@pkievit-copado pkievit-copado added the potential bug Might be a bug, requires further clarification label Apr 24, 2023
@damies13 damies13 added bug Something isn't working and removed potential bug Might be a bug, requires further clarification labels Apr 24, 2023
@damies13
Copy link
Owner

I can confirm it's related to this issue you mentioned in Discord

https://stackoverflow.com/questions/69792938/tkinter-fonts-in-a-seprate-file

When using -n there is no tkinter window (nor should there be), but rs_setting_get_font function is using tkinter to load the operating system's font list as I was trying to prevent another bug in the GUI where it would try load the preview with a font chosen in the template that didn't exist in the OS. Here's the offending code:

	def rs_setting_get_font(self):
		fontlst = list(tkFont.families())
		base.debugmsg(9, "fontlst", fontlst)
		value = self.rs_setting_get('font')
		if value not in fontlst:
			value = None
		if value is None:
			# Verdana, Tahoma, Arial, Helvetica, sans-serif
			fontorder = ['Helvetica', 'Verdana', 'Tahoma', 'Arial', 'FreeSans']
			for fnt in fontorder:
				if fnt in fontlst:
					return fnt
			for fnt in fontlst:
				if 'Sans' in fnt or 'sans' in fnt:
					return fnt
			return 'sans-serif'
		else:
			return value

My initial thought is to not load the font list first, but rather read the value form the template and if running with -n just return the font name without any checks, then only if in GUI mode do the checks.

My concern here is how the docx and xlsx generation will work, will they error is the font is not found?
The HTML generation will work and the browsers will handle the situation if the font is not there.

I guess I need to try it out and see what happens

@damies13 damies13 added this to the V1.1.1 milestone Apr 24, 2023
damies13 added a commit that referenced this issue Apr 25, 2023
damies13 added a commit that referenced this issue Apr 25, 2023
Issue #144
Still expect this to fail as fix is not implimented
damies13 added a commit that referenced this issue Apr 25, 2023
damies13 added a commit that referenced this issue Apr 25, 2023
Hopefully this doesn't break something else, particularly i'm concerned  about docx and xlsx generation, lets see
damies13 added a commit that referenced this issue Apr 25, 2023
Add -g 1 so the output file is shown
check filename.extension rather than just extension in output
Issue #144
damies13 added a commit that referenced this issue Apr 25, 2023
Regression Test case for Issue #144 found it :-)
damies13 added a commit that referenced this issue Apr 25, 2023
Issue #144
For some reason stdout is empty when RC=0
damies13 added a commit that referenced this issue Apr 25, 2023
use ${pyfile} variable
Issue #144
damies13 added a commit that referenced this issue Apr 25, 2023
@damies13
Copy link
Owner

  • Regression test added
  • Fix Applied

This is the first issue with a regression test as I added the ability to run regression tests on Windows, Mac and Linux (Ubuntu) on several versions of python each as part of V1.1.0. Now there is a regression test for this we should be able to catch it if this issue occurs again.

damies13 added a commit that referenced this issue Apr 25, 2023
damies13 added a commit that referenced this issue Apr 27, 2023
This is the same issue as Issue #97 which was fixed in Release 0.8.2 well before reporter was released.
Luckily the regression tests for Issue #144 picked it up as there was Thai characters in the template.
damies13 added a commit that referenced this issue Apr 27, 2023
@damies13
Copy link
Owner

So far this bug report has been very productive, in addition to the original issue it's also found:

Now all builds are passing except Manager (macos-latest, 3.10), which I'm going to ignore for now as:

@damies13
Copy link
Owner

Merged into release v1.1.1 branch

ArekKuczynski added a commit to NiceProjectPoland/rfswarm that referenced this issue Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants