Emit specific error if protocol modules not found
This has now tripped up more than one user (see issues #47 and #53). There is a note in the README about this, but it's easy to miss if you don't read it thoroughly.
This commit is contained in:
parent
7cf1d62658
commit
48aebd6289
1 changed files with 11 additions and 3 deletions
|
@ -1,11 +1,19 @@
|
|||
#!/usr/bin/python3
|
||||
"""Simple example of get_status request using grpc call directly."""
|
||||
|
||||
import sys
|
||||
|
||||
import grpc
|
||||
|
||||
from spacex.api.device import device_pb2
|
||||
from spacex.api.device import device_pb2_grpc
|
||||
from spacex.api.device import dish_pb2
|
||||
try:
|
||||
from spacex.api.device import device_pb2
|
||||
from spacex.api.device import device_pb2_grpc
|
||||
from spacex.api.device import dish_pb2
|
||||
except ModuleNotFoundError:
|
||||
print("This script requires the generated gRPC protocol modules. "
|
||||
"See README file for details.",
|
||||
file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# Note that if you remove the 'with' clause here, you need to separately
|
||||
# call channel.close() when you're done with the gRPC connection.
|
||||
|
|
Loading…
Reference in a new issue