From 14511582f288d46abf6168e3689daa110b50f100 Mon Sep 17 00:00:00 2001 From: Alex Thiele Date: Thu, 14 Mar 2024 10:00:05 -0700 Subject: [PATCH] push push push --- onshape_urdf_exporter/__main__.py | 24 ++++++++++++++------ onshape_urdf_exporter/onshape_api/onshape.py | 6 ++++- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/onshape_urdf_exporter/__main__.py b/onshape_urdf_exporter/__main__.py index d1b19c1..22853da 100644 --- a/onshape_urdf_exporter/__main__.py +++ b/onshape_urdf_exporter/__main__.py @@ -94,13 +94,23 @@ def addPart(occurrence, matrix): ).hexdigest() else: shortend_configuration = part["configuration"] - stl = client.part_studio_stl_m( - part["documentId"], - part["documentMicroversion"], - part["elementId"], - part["partId"], - shortend_configuration, - ) + + try: + stl = client.part_studio_stl_m( + part["documentId"], + part["documentMicroversion"], + part["elementId"], + part["partId"], + shortend_configuration, + ) + except ConnectionRefusedError as e: + print( + Fore.RED + + f"Skipping part {part['name']}, because of connection error: {e}" + + Style.RESET_ALL + ) + return + stl_file.write_bytes(stl) if config.simplify_stls: simplify_stl(stl_file) diff --git a/onshape_urdf_exporter/onshape_api/onshape.py b/onshape_urdf_exporter/onshape_api/onshape.py index 1a1346c..1485092 100644 --- a/onshape_urdf_exporter/onshape_api/onshape.py +++ b/onshape_urdf_exporter/onshape_api/onshape.py @@ -254,9 +254,13 @@ def request(self, method, path, query={}, headers={}, body={}, base_url=None): print( "HINT: Check that your access rights are correct, and that the clock on your computer is set correctly" ) - exit() + raise ConnectionRefusedError( + "HINT: Check that your access rights are correct, and that the clock on your computer is set correctly" + ) if self._logging: utils.log("request failed, details: " + res.text, level=1) + exit() + else: if self._logging: utils.log("request succeeded, details: " + res.text)