WireViz icon indicating copy to clipboard operation
WireViz copied to clipboard

Handle OSError [errno.EINVAL] that might be raised in Windows

Open kvid opened this issue 1 year ago • 3 comments

Suggested fix posted in https://github.com/wireviz/WireViz/issues/344#issuecomment-2113476151

Please verify that this fixes #344 and report back.

The base branch of this PR is master for the time beeing, but it should be changed to a new release/v0.4.1-rc before any merge-in. #345 should also be fixed and updating the changelog before releasing the hotfix.

kvid avatar May 15 '24 22:05 kvid

This commit fixed it for me 👍

> python -V
Python 3.12.2
> dot -V
dot - graphviz version 11.0.0 (20240428.1522)
> ver
Microsoft Windows [Version 10.0.19045.4291]

nanangp avatar May 16 '24 03:05 nanangp

pip uninstall wireviz

pip install wireviz

I have replaced wireviz.py with the edited file

->

`PS C:\Users\adam\Wireviz\psyduck\J2_GND> wireviz j2.yml

WireViz 0.4 Input file: j2.yml Output file: j2.[html|png|svg|tsv] Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in run_code File "C:\Users\adam\AppData\Local\Programs\Python\Python311\Scripts\wireviz.exe_main.py", line 7, in File "C:\Users\adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1157, in call return self.main(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1078, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "C:\Users\adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 783, in invoke return __callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\wireviz\wv_cli.py", line 141, in wireviz wv.parse( File "C:\Users\adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\wireviz\wireviz.py", line 382, in parse harness.output(filename=output_file, fmt=output_formats, view=False) File "C:\Users\adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\wireviz\Harness.py", line 708, in output generate_html_output(filename, bomlist, self.metadata, self.options) File "C:\Users\adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\wireviz\wv_html.py", line 37, in generate_html_output html = open_file_read(templatefile).read() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\wireviz\wv_helper.py", line 117, in open_file_read return open(filename, "r", encoding="UTF-8") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\wireviz\templates\simple.html'`

freiadam avatar May 16 '24 07:05 freiadam

@freiadam wrote:

[...] "C:\Users\adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\wireviz\wv_helper.py", line 117, in open_file_read return open(filename, "r", encoding="UTF-8") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\adam\AppData\Local\Programs\Python\Python311\Lib\site-packages\wireviz\templates\simple.html'`

Thank you for testing this PR. The exception you report now seems to be caused by the other bug already reported in #345. Please also comment there about your findings if you agree.

The fact that you got an exception trying to read a template file (that is part of HTML output after processing all YAML input) proves that the bug targeted by this PR was not triggered, because the #344 bug is located in the code part that opens the YAML input before it gets parsed. 😃

kvid avatar May 16 '24 07:05 kvid

Same error as Original post.

wireviz-0.4.1.dev0 fixed issue.

ExtremeVic avatar Jun 10 '24 15:06 ExtremeVic