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

Crashes for some parameter combinations involving --format and --output #276

Closed
1 task done
Arnaud-D opened this issue Aug 7, 2022 · 3 comments
Closed
1 task done
Labels
bug Something isn't working

Comments

@Arnaud-D
Copy link

Arnaud-D commented Aug 7, 2022

I have searched for an opened issue and didn't find my bug

  • I confirm I didn't find any issue regarding my bug

Version of Kosmorro

0.10

Version of Python

3.10

Operating system

Linux

Installation source

PyPI

Bug description

When launching with kosmorro --output=ephemeride.pdf, kosmorro crashes with the following trace:

Traceback (most recent call last):
  File "/home/arnaud/.local/bin/kosmorro", line 8, in <module>
    sys.exit(main())
  File "/home/arnaud/.local/lib/python3.10/site-packages/kosmorro/__main__.py", line 316, in main
    sys.exit(run())
  File "/home/arnaud/.local/lib/python3.10/site-packages/kosmorro/__main__.py", line 107, in run
    output_file.write(pdf_content)
TypeError: a bytes-like object is required, not 'str'

I would expect an error for missing/wrong parameters instead of a crash.

Alternatively, kosmorro could guess the desired output based on the extension of the output argument, and inform the user that this decision has been made.


Also, kosmorro --format=json --output=ephemeride.json and kosmorro --format=text --output="ephemeride.txt" crash with similar errors.

Here the expected behavior would be to write a file with the json or text output.

Alternatively kosmorro could ignore the parameter and warn the user about it.


For comparison, the following commands works fine:

kosmorro --format=pdf --output=ephemeride.pdf
kosmorro --format=json
kosmorro --format=text
@Arnaud-D Arnaud-D added the bug Something isn't working label Aug 7, 2022
@Deuchnord
Copy link
Member

Alternatively, kosmorro could guess the desired output based on the extension of the output argument, and inform the user that this decision has been made.

This is already implemented and will be available in v1.0 (#197) :)

Thanks for the bug report, I'll check what's happening there

@Deuchnord
Copy link
Member

After some testing, it looks like the issue described here does not happen in the development branch for v1.0, so I don't think it's worth a fix for v0.10.
As a workaround, you may redirect the output with the shell:

kosmorro --format=json > output.json

@Arnaud-D Does it sound good for you?

@Arnaud-D
Copy link
Author

Arnaud-D commented Aug 9, 2022

Sounds good. 👍

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