Add more exception except
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from serial import SerialException
|
||||||
|
|
||||||
from lerobot import available_cameras, available_motors, available_robots
|
from lerobot import available_cameras, available_motors, available_robots
|
||||||
from lerobot.common.utils.utils import init_hydra_config
|
from lerobot.common.utils.utils import init_hydra_config
|
||||||
@@ -43,9 +44,22 @@ def is_robot_available(robot_type):
|
|||||||
robot.connect()
|
robot.connect()
|
||||||
del robot
|
del robot
|
||||||
return True
|
return True
|
||||||
except Exception:
|
|
||||||
|
except ModuleNotFoundError as e:
|
||||||
|
print(f"\nA {robot_type} robot is not available.")
|
||||||
|
print(f"\nInstall module '{e.name}'")
|
||||||
|
traceback.print_exc()
|
||||||
|
return False
|
||||||
|
|
||||||
|
except SerialException:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
print(f"\nA {robot_type} robot is not available.")
|
print(f"\nA {robot_type} robot is not available.")
|
||||||
|
print("\nNo physical motors bus detected.")
|
||||||
|
return False
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
print(f"\nA {robot_type} robot is not available.")
|
||||||
|
traceback.print_exc()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@@ -61,11 +75,24 @@ def is_camera_available(camera_type):
|
|||||||
camera.connect()
|
camera.connect()
|
||||||
del camera
|
del camera
|
||||||
return True
|
return True
|
||||||
except Exception:
|
|
||||||
|
except ModuleNotFoundError as e:
|
||||||
print(f"\nA {camera_type} camera is not available.")
|
print(f"\nA {camera_type} camera is not available.")
|
||||||
|
print(f"\nInstall module '{e.name}'")
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
print(f"\nA {camera_type} camera is not available.")
|
||||||
|
print("\nNo physical camera detected.")
|
||||||
|
traceback.print_exc()
|
||||||
|
return False
|
||||||
|
|
||||||
|
# except Exception as e:
|
||||||
|
# print(f"\nA {camera_type} camera is not available.")
|
||||||
|
# traceback.print_exc()
|
||||||
|
# return False
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def is_motor_available(motor_type):
|
def is_motor_available(motor_type):
|
||||||
@@ -79,9 +106,22 @@ def is_motor_available(motor_type):
|
|||||||
motors_bus.connect()
|
motors_bus.connect()
|
||||||
del motors_bus
|
del motors_bus
|
||||||
return True
|
return True
|
||||||
except Exception:
|
|
||||||
traceback.print_exc()
|
except ModuleNotFoundError as e:
|
||||||
print(f"\nA {motor_type} motor is not available.")
|
print(f"\nA {motor_type} motor is not available.")
|
||||||
|
print(f"\nInstall module '{e.name}'")
|
||||||
|
traceback.print_exc()
|
||||||
|
return False
|
||||||
|
|
||||||
|
except SerialException:
|
||||||
|
print(f"\nA {motor_type} motor is not available.")
|
||||||
|
print("\nNo physical motors bus detected.")
|
||||||
|
traceback.print_exc()
|
||||||
|
return False
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
print(f"\nA {motor_type} motor is not available.")
|
||||||
|
traceback.print_exc()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user