Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Raise exception if not connected #671

Merged
merged 1 commit into from
Sep 29, 2023

Conversation

erikbosch
Copy link
Contributor

@erikbosch erikbosch commented Sep 25, 2023

Fixes #667

With this change, if calling authorize before connect you get:


erik@debian3:~/kuksa.val/kuksa-client$ ./hej.py 
Traceback (most recent call last):
  File "/home/erik/kuksa.val/kuksa-client/./hej.py", line 105, in <module>
    client.authorize(token)
  File "/home/erik/kuksa.val/kuksa-client/kuksa_client/grpc/__init__.py", line 678, in wrapper
    raise Exception("Server not connected! Call connect() before using this command!")
Exception: Server not connected! Call connect() before using this command!
erik@debian3:~/kuksa.val/kuksa-client$ 

PR consist of two types of changes:

  • Exception instead of info for both sync and async
  • Alignment of connection check, previously connection was checked just for subset

Copy link
Contributor

@lukasmittag lukasmittag left a comment

Choose a reason for hiding this comment

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

For the cli it works in this way:

Test Client> disconnect 
gRPC channel disconnected.
Test Client> authorize ../jwt/provide-vehicle-speed.token 
Connecting to VSS server at 127.0.0.1 port 55555 using KUKSA GRPC protocol.
TLS will not be used.
INFO 2023-09-25 13:19:48,502 kuksa_client.grpc No Root CA present, it will not be possible to use a secure connection!
INFO 2023-09-25 13:19:48,502 kuksa_client.grpc.aio Establishing insecure channel
gRPC channel connected.
"Authenticated"

and for a quick example program it worked.

Traceback (most recent call last):
  File "example.py", line 7, in <module>
    client.authorize(token=token)
  File "/home/imu6fe/kuksa.val/kuksa-client/kuksa_client/grpc/__init__.py", line 678, in wrapper
    raise Exception("Server not connected! Call connect() before using this command!")
Exception: Server not connected! Call connect() before using this command!

@erikbosch erikbosch force-pushed the erik_667 branch 3 times, most recently from 47caceb to 9093917 Compare September 26, 2023 07:42
@erikbosch
Copy link
Contributor Author

PR extended to also cover async. Also aligned connection check for all methods

@erikbosch erikbosch requested a review from argerus September 26, 2023 07:50
@erikbosch erikbosch marked this pull request as ready for review September 26, 2023 07:50
@erikbosch erikbosch marked this pull request as draft September 26, 2023 07:57
@erikbosch
Copy link
Contributor Author

Need to do some more testing

Also make sure that we have consistent check for available connection
Fixes eclipse-archived#667
@erikbosch erikbosch marked this pull request as ready for review September 26, 2023 13:06
@erikbosch erikbosch merged commit aa9df3d into eclipse-archived:master Sep 29, 2023
@erikbosch erikbosch deleted the erik_667 branch September 29, 2023 09:26
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unintuitive behaviour in kuksa_client
2 participants