diff --git a/src/crappy/actuator/__init__.py b/src/crappy/actuator/__init__.py index d3ea3e06..be1b5ab8 100644 --- a/src/crappy/actuator/__init__.py +++ b/src/crappy/actuator/__init__.py @@ -16,4 +16,5 @@ from .meta_actuator import MetaActuator, Actuator +from ._deprecated import deprecated_actuators actuator_dict: Dict[str, Type[Actuator]] = MetaActuator.classes diff --git a/src/crappy/actuator/_deprecated.py b/src/crappy/actuator/_deprecated.py new file mode 100644 index 00000000..4ae993d2 --- /dev/null +++ b/src/crappy/actuator/_deprecated.py @@ -0,0 +1,9 @@ +# coding: utf-8 + +deprecated_actuators = {'CM_drive': 'SchneiderMDrive23', + 'Fake_motor': 'FakeDCMotor', + 'Motorkit_pump': 'DCMotorHat', + 'Oriental': 'OrientalARDK', + 'Pololu_tic': 'PololuTic', + 'Servostar': 'ServoStar300', + 'Tra6ppd': 'NewportTRA6PPD'} diff --git a/src/crappy/blocks/__init__.py b/src/crappy/blocks/__init__.py index 9364bad5..130cc3c1 100644 --- a/src/crappy/blocks/__init__.py +++ b/src/crappy/blocks/__init__.py @@ -30,3 +30,7 @@ from . import generator_path from . import camera_processes + +from ._deprecated import (AutoDrive, Client_server, Displayer, DISVE, Drawing, + Fake_machine, GUI, Hdf_recorder, Mean_block, + Multiplex, Reader, Video_extenso) diff --git a/src/crappy/blocks/_deprecated.py b/src/crappy/blocks/_deprecated.py new file mode 100644 index 00000000..5e9aaadb --- /dev/null +++ b/src/crappy/blocks/_deprecated.py @@ -0,0 +1,205 @@ +# coding: utf-8 + +from .meta_block import Block + + +class AutoDrive(Block): + """Empty class for signaling an object of version 1.5 whose name changed in + version 2.0 and is now deprecated. + + The new name of the correct object to use is given. + """ + + def __init__(self, *_, **__) -> None: + """Simply raises the exception when instantiating the object.""" + + super().__init__() + + raise NotImplementedError(f"The {type(self).__name__} Block was renamed " + f"to AutoDriveVideoExtenso in version 2.0.0 ! " + f"Check the documentation for more information.") + + +class Client_server(Block): + """Empty class for signaling an object of version 1.5 whose name changed in + version 2.0 and is now deprecated. + + The new name of the correct object to use is given. + """ + + def __init__(self, *_, **__) -> None: + """Simply raises the exception when instantiating the object.""" + + super().__init__() + + raise NotImplementedError(f"The {type(self).__name__} Block was renamed " + f"to ClientServer in version 2.0.0 ! " + f"Check the documentation for more information.") + + +class Displayer(Block): + """Empty class for signaling an object of version 1.5 that wa removed in + version 2.0.O.""" + + def __init__(self, *_, **__) -> None: + """Simply raises the exception when instantiating the object.""" + + super().__init__() + + raise NotImplementedError(f"The {type(self).__name__} Block was removed " + f"in version 2.0.0 ! It is now contained " + f"directly in the Camera Block. " + f"Check the documentation for more information.") + + +class DISVE(Block): + """Empty class for signaling an object of version 1.5 whose name changed in + version 2.0 and is now deprecated. + + The new name of the correct object to use is given. + """ + + def __init__(self, *_, **__) -> None: + """Simply raises the exception when instantiating the object.""" + + super().__init__() + + raise NotImplementedError(f"The {type(self).__name__} Block was renamed " + f"to DICVE in version 2.0.0 ! " + f"Check the documentation for more information.") + + +class Drawing(Block): + """Empty class for signaling an object of version 1.5 whose name changed in + version 2.0 and is now deprecated. + + The new name of the correct object to use is given. + """ + + def __init__(self, *_, **__) -> None: + """Simply raises the exception when instantiating the object.""" + + super().__init__() + + raise NotImplementedError(f"The {type(self).__name__} Block was renamed " + f"to Canvas in version 2.0.0 ! " + f"Check the documentation for more information.") + + +class Fake_machine(Block): + """Empty class for signaling an object of version 1.5 whose name changed in + version 2.0 and is now deprecated. + + The new name of the correct object to use is given. + """ + + def __init__(self, *_, **__) -> None: + """Simply raises the exception when instantiating the object.""" + + super().__init__() + + raise NotImplementedError(f"The {type(self).__name__} Block was renamed " + f"to FakeMachine in version 2.0.0 ! " + f"Check the documentation for more information.") + + +class GUI(Block): + """Empty class for signaling an object of version 1.5 whose name changed in + version 2.0 and is now deprecated. + + The new name of the correct object to use is given. + """ + + def __init__(self, *_, **__) -> None: + """Simply raises the exception when instantiating the object.""" + + super().__init__() + + raise NotImplementedError(f"The {type(self).__name__} Block was renamed " + f"to Button in version 2.0.0 ! " + f"Check the documentation for more information.") + + +class Hdf_recorder(Block): + """Empty class for signaling an object of version 1.5 whose name changed in + version 2.0 and is now deprecated. + + The new name of the correct object to use is given. + """ + + def __init__(self, *_, **__) -> None: + """Simply raises the exception when instantiating the object.""" + + super().__init__() + + raise NotImplementedError(f"The {type(self).__name__} Block was renamed " + f"to HDFRecorder in version 2.0.0 ! " + f"Check the documentation for more information.") + + +class Mean_block(Block): + """Empty class for signaling an object of version 1.5 whose name changed in + version 2.0 and is now deprecated. + + The new name of the correct object to use is given. + """ + + def __init__(self, *_, **__) -> None: + """Simply raises the exception when instantiating the object.""" + + super().__init__() + + raise NotImplementedError(f"The {type(self).__name__} Block was renamed " + f"to MeanBlock in version 2.0.0 ! " + f"Check the documentation for more information.") + + +class Multiplex(Block): + """Empty class for signaling an object of version 1.5 whose name changed in + version 2.0 and is now deprecated. + + The new name of the correct object to use is given. + """ + + def __init__(self, *_, **__) -> None: + """Simply raises the exception when instantiating the object.""" + + super().__init__() + + raise NotImplementedError(f"The {type(self).__name__} Block was renamed " + f"to Multiplexer in version 2.0.0 ! " + f"Check the documentation for more information.") + + +class Reader(Block): + """Empty class for signaling an object of version 1.5 whose name changed in + version 2.0 and is now deprecated. + + The new name of the correct object to use is given. + """ + + def __init__(self, *_, **__) -> None: + """Simply raises the exception when instantiating the object.""" + + super().__init__() + + raise NotImplementedError(f"The {type(self).__name__} Block was renamed " + f"to LinkReader in version 2.0.0 ! " + f"Check the documentation for more information.") + + +class Video_extenso(Block): + """Empty class for signaling an object of version 1.5 whose name changed in + version 2.0 and is now deprecated. + + The new name of the correct object to use is given. + """ + + def __init__(self, *_, **__) -> None: + """Simply raises the exception when instantiating the object.""" + + super().__init__() + + raise NotImplementedError(f"The {type(self).__name__} Block was renamed " + f"to VideoExtenso in version 2.0.0 ! " + f"Check the documentation for more information.") diff --git a/src/crappy/blocks/camera.py b/src/crappy/blocks/camera.py index 709563cf..73a8b105 100644 --- a/src/crappy/blocks/camera.py +++ b/src/crappy/blocks/camera.py @@ -13,7 +13,7 @@ from .meta_block import Block from .camera_processes import Displayer, ImageSaver, CameraProcess -from ..camera import camera_dict, Camera as BaseCam +from ..camera import camera_dict, Camera as BaseCam, deprecated_cameras from ..tool.camera_config import CameraConfig from .._global import CameraPrepareError, CameraRuntimeError, CameraConfigError @@ -206,6 +206,13 @@ def __init__(self, self.niceness = -10 self.debug = debug + # Checking for deprecated names + if camera in deprecated_cameras: + raise NotImplementedError( + f"The {camera} Camera was deprecated in version 2.0.0, and renamed " + f"to {deprecated_cameras[camera]} ! Please update your code " + f"accordingly and check the documentation for more information") + # Checking if the requested camera exists in Crappy if image_generator is None: if camera not in camera_dict: diff --git a/src/crappy/blocks/ioblock.py b/src/crappy/blocks/ioblock.py index 3feba950..88541b8e 100644 --- a/src/crappy/blocks/ioblock.py +++ b/src/crappy/blocks/ioblock.py @@ -4,7 +4,7 @@ import logging from .meta_block import Block -from ..inout import inout_dict, InOut +from ..inout import inout_dict, InOut, deprecated_inouts from ..tool.ft232h import USBServer @@ -156,6 +156,13 @@ def __init__(self, self._trig_label = trigger_label + # Checking for deprecated names + if name in deprecated_inouts: + raise NotImplementedError( + f"The {name} InOut was deprecated in version 2.0.0, and renamed " + f"to {deprecated_inouts[name]} ! Please update your code " + f"accordingly and check the documentation for more information") + # Checking that all the given actuators are valid if name not in inout_dict: possible = ', '.join(sorted(inout_dict.keys())) diff --git a/src/crappy/blocks/machine.py b/src/crappy/blocks/machine.py index 25ee3100..3c921ab7 100644 --- a/src/crappy/blocks/machine.py +++ b/src/crappy/blocks/machine.py @@ -6,7 +6,7 @@ import logging from .meta_block import Block -from ..actuator import actuator_dict, Actuator +from ..actuator import actuator_dict, Actuator, deprecated_actuators from ..tool.ft232h import USBServer @@ -144,6 +144,15 @@ def __init__(self, # The list of all the Actuator types to instantiate self._types = [actuator['type'] for actuator in actuators] + # Checking for deprecated names + deprecated = [type_ for type_ in self._types + if type_ in deprecated_actuators] + for type_ in deprecated: + raise NotImplementedError( + f"The {type_} Actuator was deprecated in version 2.0.0, and renamed " + f"to {deprecated_actuators[type_]} ! Please update your code " + f"accordingly and check the documentation for more information") + # Checking that all the given actuators are valid if not all(type_ in actuator_dict for type_ in self._types): unknown = ', '.join(tuple(type_ for type_ in self._types if type_ diff --git a/src/crappy/camera/__init__.py b/src/crappy/camera/__init__.py index 53143f91..6435f5eb 100644 --- a/src/crappy/camera/__init__.py +++ b/src/crappy/camera/__init__.py @@ -27,4 +27,5 @@ else: from .gstreamer_camera_basic import CameraGstreamer +from ._deprecated import deprecated_cameras camera_dict: Dict[str, Type[Camera]] = MetaCamera.classes diff --git a/src/crappy/camera/_deprecated.py b/src/crappy/camera/_deprecated.py new file mode 100644 index 00000000..c945d40a --- /dev/null +++ b/src/crappy/camera/_deprecated.py @@ -0,0 +1,13 @@ +# coding: utf-8 + +deprecated_cameras = {'Bispectral': 'BiSpectral', + 'Cl_camera': 'BaslerIronmanCameraLink', + 'Fake_camera': 'FakeCamera', + 'File_reader': 'FileReader', + 'Camera_gstreamer': 'CameraGstreamer', + 'Jai8': 'JaiGO5000CPMCL8Bits', + 'Jai': 'JaiGO5000CPMCL', + 'Camera_opencv': 'CameraOpencv', + 'Picamera': 'RaspberryPiCamera', + 'Seek_thermal_pro': 'SeekThermalPro', + 'Xiapi': 'XiAPI'} diff --git a/src/crappy/inout/__init__.py b/src/crappy/inout/__init__.py index 926bca56..b7752727 100644 --- a/src/crappy/inout/__init__.py +++ b/src/crappy/inout/__init__.py @@ -34,4 +34,5 @@ from .meta_inout import InOut, MetaIO # All the inout objects +from ._deprecated import deprecated_inouts inout_dict: Dict[str, Type[InOut]] = MetaIO.classes diff --git a/src/crappy/inout/_deprecated.py b/src/crappy/inout/_deprecated.py new file mode 100644 index 00000000..d62637e7 --- /dev/null +++ b/src/crappy/inout/_deprecated.py @@ -0,0 +1,21 @@ +# coding: utf-8 + +deprecated_inouts = {'Ads1115': 'ADS1115', + 'Daqmx': 'DAQmx', + 'Fake_inout': 'FakeInOut', + 'Gpio_pwm': 'GPIOPWM', + 'Gpio_switch': 'GPIOSwitch', + 'Gsm': 'Sim868', + 'Koll': 'KollmorgenAKDPDMM', + 'Labjack_t7': 'LabjackT7', + 'Labjack_ue9': 'LabjackUE9', + 'Mcp9600': 'MCP9600', + 'Mprls': 'MPRLS', + 'Nau7802': 'NAU7802', + 'Nidaqmx': 'NIDAQmx', + 'Opsens': 'HandySens', + 'Pijuice': 'PiJuice', + 'Spectrum': 'SpectrumM2I4711', + 'T7_streamer': 'T7Streamer', + 'Waveshare_ad_da': 'WaveshareADDA', + 'Waveshare_high_precision': 'WaveshareHighPrecision'}