Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Fix server_type handling #144

Merged
merged 1 commit into from
Oct 20, 2023

Conversation

erikbosch
Copy link
Contributor

Previously you would get an error whatever you specified. This change behavior to expect lower case name:

I.e. you should call:

erik@debian3:~/kuksa.val.feeders/dbc2val$ ./dbcfeeder.py --server-type kuksa_databroker
2023-09-19 12:58:13,256 INFO dbcfeeder: Reading configuration from file: config/dbc_feeder.ini
2023-09-19 12:58:13,257 INFO dbcfeeder: DBC2VAL mode is: True
2023-09-19 12:58:13,257 INFO dbcfeeder: VAL2DBC mode is: False
...

If you try uppercase you get an error:

erik@debian3:~/kuksa.val.feeders/dbc2val$ ./dbcfeeder.py --server-type KUKSA_DATABROKER
usage: dbcfeeder.py [-h] [--config FILE] [--dbcfile FILE] [--dumpfile FILE] [--canport DEVICE] [--use-j1939] [--use-socketcan] [--mapping FILE] [--dbc-default FILE] [--server-type {kuksa_val_server,kuksa_databroker}] [--lax-dbc-parsing]
                    [--dbc2val] [--no-dbc2val] [--val2dbc] [--no-val2dbc]
dbcfeeder.py: error: argument --server-type: invalid choice: 'KUKSA_DATABROKER' (choose from 'kuksa_val_server', 'kuksa_databroker')

How it worked before this PR

You were doomed if you used kuksa_databroker

erik@debian3:~/kuksa.val.feeders/dbc2val$ ./dbcfeeder.py --server-type kuksa_databroker
usage: dbcfeeder.py [-h] [--config FILE] [--dbcfile FILE] [--dumpfile FILE] [--canport DEVICE] [--use-j1939] [--use-socketcan] [--mapping FILE] [--dbc-default FILE] [--server-type {KUKSA_VAL_SERVER,KUKSA_DATABROKER}] [--lax-dbc-parsing]
                    [--dbc2val] [--no-dbc2val] [--val2dbc] [--no-val2dbc]
dbcfeeder.py: error: argument --server-type: invalid choice: 'kuksa_databroker' (choose from 'KUKSA_VAL_SERVER', 'KUKSA_DATABROKER')

You were also doomed if you used KUKSA_DATABROKER

erik@debian3:~/kuksa.val.feeders/dbc2val$ ./dbcfeeder.py --server-type KUKSA_DATABROKER
2023-09-19 12:56:22,045 INFO dbcfeeder: Reading configuration from file: config/dbc_feeder.ini
2023-09-19 12:56:22,046 INFO dbcfeeder: DBC2VAL mode is: True
2023-09-19 12:56:22,046 INFO dbcfeeder: VAL2DBC mode is: False
Traceback (most recent call last):
  File "/home/erik/kuksa.val.feeders/dbc2val/./dbcfeeder.py", line 703, in <module>
    sys.exit(main(sys.argv))
  File "/home/erik/kuksa.val.feeders/dbc2val/./dbcfeeder.py", line 608, in main
    kuksa_val_client = _get_kuksa_val_client(args, config)
  File "/home/erik/kuksa.val.feeders/dbc2val/./dbcfeeder.py", line 407, in _get_kuksa_val_client
    server_type = ServerType(server_type_name)
  File "/usr/local/lib/python3.10/enum.py", line 385, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/lib/python3.10/enum.py", line 710, in __new__
    raise ve_exc
ValueError: 'KUKSA_DATABROKER' is not a valid ServerType

Previously you would get an error whatever you specified
@erikbosch
Copy link
Contributor Author

erikbosch commented Sep 19, 2023

FYI: @sophokles73 @SebastianSchildt

I believe it looks better to request lower case name as argument. I also added some basic tests. Lower case names is also what is used in the README.md file

@erikbosch
Copy link
Contributor Author

Candidate for v0.4.1 - can you review @SebastianSchildt @lukasmittag

Copy link
Contributor

@SebastianSchildt SebastianSchildt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works.

@SebastianSchildt SebastianSchildt merged commit 6863fe2 into eclipse-kuksa:main Oct 20, 2023
6 checks passed
@erikbosch erikbosch deleted the erik_server_arg branch February 27, 2024 11:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants