diff --git a/examples/python/README.md b/examples/python/README.md index 23ba5d7..a10f602 100644 --- a/examples/python/README.md +++ b/examples/python/README.md @@ -54,11 +54,14 @@ STELLARSTATION_API_SATELLITE_ID -> *an integer, for example: 123* STELLARSTATION_API_CHANNEL_ID -> *an integer, for example: 123* +STELLARSTATION_API_URL -> *a string, for example: stream.qa.stellarstation.com* + For example, if you're using Debian, you would either execute the following in your terminal or add the following to your bash script (for permanency): ```bash $ export STELLARSTATION_API_KEY_PATH=~/keys/your_personal_key.json $ export STELLARSTATION_API_SATELLITE_ID=123 $ export STELLARSTATION_API_CHANNEL_ID=123 +$ export STELLARSTATION_API_URL=stream.qa.stellarstation.com ``` If you added them to your bash script don't forget to re-source. @@ -135,11 +138,14 @@ STELLARSTATION_API_SATELLITE_ID -> *an integer, for example: 123* STELLARSTATION_API_CHANNEL_ID -> *an integer, for example: 123* +STELLARSTATION_API_URL -> *a string, for example: stream.qa.stellarstation.com* + Here's an example: ```powershell PS C:\> $Env:STELLARSTATION_API_KEY_PATH="C:\Users\Your Username\keys\your_personal_key.json" PS C:\> $Env:STELLARSTATION_API_SATELLITE_ID="123" PS C:\> $Env:STELLARSTATION_API_CHANNEL_ID="123" +PS C:\> $Env:STELLARSTATION_API_URL="stream.qa.stellarstation.com" ``` ,or, diff --git a/examples/python/for_satellite_operators/configure_radio.py b/examples/python/for_satellite_operators/configure_radio.py index ca0812b..ddd0ab0 100644 --- a/examples/python/for_satellite_operators/configure_radio.py +++ b/examples/python/for_satellite_operators/configure_radio.py @@ -260,9 +260,9 @@ def generate_request(request_queue, thread_sts_queue): # thread_sts_queue.put("Sent Request: {}".format(str(req))) yield req -def run_streamer(api_key_path, request_queue, thread_sts_queue): +def run_streamer(api_key_path, api_url_path, request_queue, thread_sts_queue): # A client is necessary to receive services from StellarStation. - client = toolkit.get_grpc_client(api_key_path, "") + client = toolkit.get_grpc_client(api_key_path, api_url_path) request_generator = generate_request(request_queue, thread_sts_queue) @@ -280,6 +280,9 @@ def run(): assert STELLARSTATION_API_KEY_PATH, "Did you properly define this environment variable on your system?" assert STELLARSTATION_API_SATELLITE_ID, "Did you properly define this environment variable on your system?" + STELLARSTATION_API_URL = os.getenv('STELLARSTATION_API_URL','stream.qa.stellarstation.com') + assert STELLARSTATION_API_URL, "Did you properly define this environment variable on your system?" + request_queue = Queue() thread_sts_queue = Queue() @@ -289,7 +292,7 @@ def run(): enable_flow_control = True) request_queue.put(stream_config_request) - streamer_thread = threading.Thread(target=run_streamer, args=(STELLARSTATION_API_KEY_PATH, request_queue, thread_sts_queue,), daemon=True) + streamer_thread = threading.Thread(target=run_streamer, args=(STELLARSTATION_API_KEY_PATH, STELLARSTATION_API_URL, request_queue, thread_sts_queue,), daemon=True) streamer_thread.start() main_menu = ConsoleMenu("Main Menu (Radio Configuration)", "This example code exhibits a CLI that allows the user to build and send transceiver configuration commands.") diff --git a/examples/python/for_satellite_operators/list_reserved_plans.py b/examples/python/for_satellite_operators/list_reserved_plans.py index 1c6d355..85e2131 100755 --- a/examples/python/for_satellite_operators/list_reserved_plans.py +++ b/examples/python/for_satellite_operators/list_reserved_plans.py @@ -33,6 +33,9 @@ def run(): assert STELLARSTATION_API_KEY_PATH, "Did you properly define this environment variable on your system?" assert STELLARSTATION_API_SATELLITE_ID, "Did you properly define this environment variable on your system?" + + STELLARSTATION_API_URL = os.getenv('STELLARSTATION_API_URL','stream.qa.stellarstation.com') + assert STELLARSTATION_API_URL, "Did you properly define this environment variable on your system?" if not STELLARSTATION_API_KEY_PATH: raise ValueError("Expected a string for environment variable STELLARSTATION_API_KEY_PATH but got {STELLARSTATION_API_KEY_PATH}.") @@ -40,7 +43,7 @@ def run(): raise ValueError("Expected a string for environment variable STELLARSTATION_API_SATELLITE_ID but got {STELLARSTATION_API_SATELLITE_ID}.") # A client is necessary to receive services from StellarStation. - client = toolkit.get_grpc_client(STELLARSTATION_API_KEY_PATH, "") + client = toolkit.get_grpc_client(STELLARSTATION_API_KEY_PATH, STELLARSTATION_API_URL) # Get the plans plans = get_plans(client, STELLARSTATION_API_SATELLITE_ID) diff --git a/examples/python/for_satellite_operators/list_successful_plan_tlm_urls.py b/examples/python/for_satellite_operators/list_successful_plan_tlm_urls.py index 7bec75f..ac6e318 100644 --- a/examples/python/for_satellite_operators/list_successful_plan_tlm_urls.py +++ b/examples/python/for_satellite_operators/list_successful_plan_tlm_urls.py @@ -34,8 +34,11 @@ def run(): assert STELLARSTATION_API_KEY_PATH, "Did you properly define this environment variable on your system?" assert STELLARSTATION_API_SATELLITE_ID, "Did you properly define this environment variable on your system?" + STELLARSTATION_API_URL = os.getenv('STELLARSTATION_API_URL','stream.qa.stellarstation.com') + assert STELLARSTATION_API_URL, "Did you properly define this environment variable on your system?" + # A client is necessary to receive services from StellarStation. - client = toolkit.get_grpc_client(STELLARSTATION_API_KEY_PATH, "") + client = toolkit.get_grpc_client(STELLARSTATION_API_KEY_PATH, STELLARSTATION_API_URL) # Get the plans plans = get_plans(client, STELLARSTATION_API_SATELLITE_ID) @@ -49,7 +52,7 @@ def run(): if plan.telemetry_metadata: print("({} of {}):{}\n".format(i + 1, len(completed_plans), plan.telemetry_metadata)) else: - print("({} of {}):{}\n".format(i + 1, len(completed_plans), "DNE")) + print("({} of {}):{}\n".format(i + 1, len(completed_plans), " Telemetry Metadata Does Not Exist")) if __name__ == '__main__': run() diff --git a/examples/python/for_satellite_operators/reserve_and_cancel_plan.py b/examples/python/for_satellite_operators/reserve_and_cancel_plan.py index 2e6208f..0988ee4 100644 --- a/examples/python/for_satellite_operators/reserve_and_cancel_plan.py +++ b/examples/python/for_satellite_operators/reserve_and_cancel_plan.py @@ -37,9 +37,12 @@ def run(): assert STELLARSTATION_API_KEY_PATH, "Did you properly define this environment variable on your system?" assert STELLARSTATION_API_SATELLITE_ID, "Did you properly define this environment variable on your system?" + + STELLARSTATION_API_URL = os.getenv('STELLARSTATION_API_URL','stream.qa.stellarstation.com') + assert STELLARSTATION_API_URL, "Did you properly define this environment variable on your system?" # A client is necessary to receive services from StellarStation. - client = toolkit.get_grpc_client(STELLARSTATION_API_KEY_PATH, "") + client = toolkit.get_grpc_client(STELLARSTATION_API_KEY_PATH, STELLARSTATION_API_URL) # Get passes that a plan can be scheduled for # Each pass in this list of plans is simply a protobuf 'Pass' message (defined in stellarstation.proto) diff --git a/examples/python/for_satellite_operators/tlm_and_cmd_stream.py b/examples/python/for_satellite_operators/tlm_and_cmd_stream.py index 202fcb3..33c4c0f 100644 --- a/examples/python/for_satellite_operators/tlm_and_cmd_stream.py +++ b/examples/python/for_satellite_operators/tlm_and_cmd_stream.py @@ -30,9 +30,12 @@ def run(): assert STELLARSTATION_API_KEY_PATH, "Did you properly define this environment variable on your system?" assert STELLARSTATION_API_SATELLITE_ID, "Did you properly define this environment variable on your system?" assert STELLARSTATION_API_CHANNEL_ID, "Did you properly define this environment variable on your system?" + + STELLARSTATION_API_URL = os.getenv('STELLARSTATION_API_URL','stream.qa.stellarstation.com') + assert STELLARSTATION_API_URL, "Did you properly define this environment variable on your system?" # A client is necessary to receive services from StellarStation. - client = toolkit.get_grpc_client(STELLARSTATION_API_KEY_PATH, "") + client = toolkit.get_grpc_client(STELLARSTATION_API_KEY_PATH, STELLARSTATION_API_URL) # Set up for stream tlm_file = open("tlm_and_cmd_stream_example_tlm.bin", "wb") diff --git a/examples/python/for_satellite_operators/toolkit.py b/examples/python/for_satellite_operators/toolkit.py index 3f258ec..35f4b99 100644 --- a/examples/python/for_satellite_operators/toolkit.py +++ b/examples/python/for_satellite_operators/toolkit.py @@ -6,8 +6,8 @@ from google.auth import jwt as google_auth_jwt from google.auth.transport import grpc as google_auth_transport_grpc + from stellarstation.api.v1 import stellarstation_pb2_grpc -import grpc # As defined in stellarstation.proto > message 'Plan' > enum Status class PlanStatus(Enum): @@ -26,15 +26,13 @@ class PlanLifecycleEventStatus(Enum): COMPLETED = 3 FAILED = 4 -def get_grpc_client(api_key_path, ssl_ca_certificate_path): +def get_grpc_client(api_key_path, api_url_path): + print('API Target: ', api_url_path) jwt_credentials = google_auth_jwt.Credentials.from_service_account_file( api_key_path, - audience='https://api.stellarstation.com', + audience=api_url_path, token_lifetime=60) - # ca = open(ssl_ca_certificate_path, 'rb') - # ssl_channel_credentials = ca.read() - google_jwt_credentials = google_auth_jwt.OnDemandCredentials.from_signing_credentials(jwt_credentials) # Increase grpc msg size allowance: @@ -44,8 +42,7 @@ def get_grpc_client(api_key_path, ssl_ca_certificate_path): channel = google_auth_transport_grpc.secure_authorized_channel( google_jwt_credentials, None, - 'api.stellarstation.com:443', - # ssl_credentials=grpc.ssl_channel_credentials(ssl_channel_credentials), + api_url_path, options = options) client = stellarstation_pb2_grpc.StellarStationServiceStub(channel)