dmxcontrol3-network-interface 3.3.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dmxc_protobuf/Client/AffinityClient_pb2.py +39 -0
- dmxc_protobuf/Client/AffinityClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/AffinityClient_pb2_grpc.py +270 -0
- dmxc_protobuf/Client/AttachableClient_pb2.py +39 -0
- dmxc_protobuf/Client/AttachableClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/AttachableClient_pb2_grpc.py +356 -0
- dmxc_protobuf/Client/AudioClient_pb2.py +39 -0
- dmxc_protobuf/Client/AudioClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/AudioClient_pb2_grpc.py +270 -0
- dmxc_protobuf/Client/BackgroundTaskClient_pb2.py +39 -0
- dmxc_protobuf/Client/BackgroundTaskClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/BackgroundTaskClient_pb2_grpc.py +141 -0
- dmxc_protobuf/Client/BeatClient_pb2.py +39 -0
- dmxc_protobuf/Client/BeatClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/BeatClient_pb2_grpc.py +356 -0
- dmxc_protobuf/Client/CommandLineClient_pb2.py +39 -0
- dmxc_protobuf/Client/CommandLineClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/CommandLineClient_pb2_grpc.py +270 -0
- dmxc_protobuf/Client/CueClient_pb2.py +39 -0
- dmxc_protobuf/Client/CueClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/CueClient_pb2_grpc.py +361 -0
- dmxc_protobuf/Client/CueTriggerClient_pb2.py +39 -0
- dmxc_protobuf/Client/CueTriggerClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/CueTriggerClient_pb2_grpc.py +98 -0
- dmxc_protobuf/Client/CuelistClient_pb2.py +39 -0
- dmxc_protobuf/Client/CuelistClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/CuelistClient_pb2_grpc.py +572 -0
- dmxc_protobuf/Client/CuelistGroupClient_pb2.py +39 -0
- dmxc_protobuf/Client/CuelistGroupClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/CuelistGroupClient_pb2_grpc.py +270 -0
- dmxc_protobuf/Client/DMXClient_pb2.py +39 -0
- dmxc_protobuf/Client/DMXClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/DMXClient_pb2_grpc.py +313 -0
- dmxc_protobuf/Client/DMXInterfaceManagementClient_pb2.py +39 -0
- dmxc_protobuf/Client/DMXInterfaceManagementClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/DMXInterfaceManagementClient_pb2_grpc.py +743 -0
- dmxc_protobuf/Client/DeviceClient_pb2.py +41 -0
- dmxc_protobuf/Client/DeviceClient_pb2.pyi +8 -0
- dmxc_protobuf/Client/DeviceClient_pb2_grpc.py +918 -0
- dmxc_protobuf/Client/ElectricityClient_pb2.py +39 -0
- dmxc_protobuf/Client/ElectricityClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/ElectricityClient_pb2_grpc.py +356 -0
- dmxc_protobuf/Client/ExecutorClient_pb2.py +39 -0
- dmxc_protobuf/Client/ExecutorClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/ExecutorClient_pb2_grpc.py +492 -0
- dmxc_protobuf/Client/FannedValueClient_pb2.py +39 -0
- dmxc_protobuf/Client/FannedValueClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/FannedValueClient_pb2_grpc.py +141 -0
- dmxc_protobuf/Client/InputClient_pb2.py +39 -0
- dmxc_protobuf/Client/InputClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/InputClient_pb2_grpc.py +1044 -0
- dmxc_protobuf/Client/ItemListClient_pb2.py +39 -0
- dmxc_protobuf/Client/ItemListClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/ItemListClient_pb2_grpc.py +356 -0
- dmxc_protobuf/Client/LogClient_pb2.py +39 -0
- dmxc_protobuf/Client/LogClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/LogClient_pb2_grpc.py +184 -0
- dmxc_protobuf/Client/MacroBoardClient_pb2.py +39 -0
- dmxc_protobuf/Client/MacroBoardClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/MacroBoardClient_pb2_grpc.py +442 -0
- dmxc_protobuf/Client/MacroClient_pb2.py +39 -0
- dmxc_protobuf/Client/MacroClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/MacroClient_pb2_grpc.py +313 -0
- dmxc_protobuf/Client/MainSwitchClient_pb2.py +39 -0
- dmxc_protobuf/Client/MainSwitchClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/MainSwitchClient_pb2_grpc.py +184 -0
- dmxc_protobuf/Client/MasterClient_pb2.py +39 -0
- dmxc_protobuf/Client/MasterClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/MasterClient_pb2_grpc.py +313 -0
- dmxc_protobuf/Client/MonitoringClient_pb2.py +39 -0
- dmxc_protobuf/Client/MonitoringClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/MonitoringClient_pb2_grpc.py +270 -0
- dmxc_protobuf/Client/ParameterClient_pb2.py +39 -0
- dmxc_protobuf/Client/ParameterClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/ParameterClient_pb2_grpc.py +227 -0
- dmxc_protobuf/Client/PluginManagementClient_pb2.py +39 -0
- dmxc_protobuf/Client/PluginManagementClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/PluginManagementClient_pb2_grpc.py +184 -0
- dmxc_protobuf/Client/PositionMappingClient_pb2.py +39 -0
- dmxc_protobuf/Client/PositionMappingClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/PositionMappingClient_pb2_grpc.py +270 -0
- dmxc_protobuf/Client/PresetClient_pb2.py +40 -0
- dmxc_protobuf/Client/PresetClient_pb2.pyi +7 -0
- dmxc_protobuf/Client/PresetClient_pb2_grpc.py +443 -0
- dmxc_protobuf/Client/ProgrammerClient_pb2.py +40 -0
- dmxc_protobuf/Client/ProgrammerClient_pb2.pyi +7 -0
- dmxc_protobuf/Client/ProgrammerClient_pb2_grpc.py +701 -0
- dmxc_protobuf/Client/ProjectClient_pb2.py +39 -0
- dmxc_protobuf/Client/ProjectClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/ProjectClient_pb2_grpc.py +1003 -0
- dmxc_protobuf/Client/RDMClient_pb2.py +39 -0
- dmxc_protobuf/Client/RDMClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/RDMClient_pb2_grpc.py +313 -0
- dmxc_protobuf/Client/SettingsClient_pb2.py +39 -0
- dmxc_protobuf/Client/SettingsClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/SettingsClient_pb2_grpc.py +485 -0
- dmxc_protobuf/Client/StageviewClient_pb2.py +39 -0
- dmxc_protobuf/Client/StageviewClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/StageviewClient_pb2_grpc.py +270 -0
- dmxc_protobuf/Client/TimecodeClient_pb2.py +39 -0
- dmxc_protobuf/Client/TimecodeClient_pb2.pyi +6 -0
- dmxc_protobuf/Client/TimecodeClient_pb2_grpc.py +1001 -0
- dmxc_protobuf/Client/UserClient_pb2.py +41 -0
- dmxc_protobuf/Client/UserClient_pb2.pyi +8 -0
- dmxc_protobuf/Client/UserClient_pb2_grpc.py +490 -0
- dmxc_protobuf/Client/__init__.py +0 -0
- dmxc_protobuf/Common/ResourceService_pb2.py +41 -0
- dmxc_protobuf/Common/ResourceService_pb2.pyi +6 -0
- dmxc_protobuf/Common/ResourceService_pb2_grpc.py +514 -0
- dmxc_protobuf/Common/Types/AffinityServiceTypes_pb2.py +45 -0
- dmxc_protobuf/Common/Types/AffinityServiceTypes_pb2.pyi +55 -0
- dmxc_protobuf/Common/Types/AffinityServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/AttachableServiceTypes_pb2.py +74 -0
- dmxc_protobuf/Common/Types/AttachableServiceTypes_pb2.pyi +195 -0
- dmxc_protobuf/Common/Types/AttachableServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Audio/AudioServiceTypes_pb2.py +62 -0
- dmxc_protobuf/Common/Types/Audio/AudioServiceTypes_pb2.pyi +183 -0
- dmxc_protobuf/Common/Types/Audio/AudioServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Audio/__init__.py +0 -0
- dmxc_protobuf/Common/Types/BackgroundTaskServiceTypes_pb2.py +43 -0
- dmxc_protobuf/Common/Types/BackgroundTaskServiceTypes_pb2.pyi +64 -0
- dmxc_protobuf/Common/Types/BackgroundTaskServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/BeatServiceTypes_pb2.py +44 -0
- dmxc_protobuf/Common/Types/BeatServiceTypes_pb2.pyi +55 -0
- dmxc_protobuf/Common/Types/BeatServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/BroadcastServiceTypes_pb2.py +37 -0
- dmxc_protobuf/Common/Types/BroadcastServiceTypes_pb2.pyi +25 -0
- dmxc_protobuf/Common/Types/BroadcastServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/CommandLineServiceTypes_pb2.py +57 -0
- dmxc_protobuf/Common/Types/CommandLineServiceTypes_pb2.pyi +122 -0
- dmxc_protobuf/Common/Types/CommandLineServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/CommonTypes_pb2.py +64 -0
- dmxc_protobuf/Common/Types/CommonTypes_pb2.pyi +161 -0
- dmxc_protobuf/Common/Types/CommonTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Cue/CueServiceTypes_pb2.py +79 -0
- dmxc_protobuf/Common/Types/Cue/CueServiceTypes_pb2.pyi +316 -0
- dmxc_protobuf/Common/Types/Cue/CueServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Cue/CueTriggerServiceTypes_pb2.py +40 -0
- dmxc_protobuf/Common/Types/Cue/CueTriggerServiceTypes_pb2.pyi +32 -0
- dmxc_protobuf/Common/Types/Cue/CueTriggerServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Cue/FannedValueServiceTypes_pb2.py +43 -0
- dmxc_protobuf/Common/Types/Cue/FannedValueServiceTypes_pb2.pyi +47 -0
- dmxc_protobuf/Common/Types/Cue/FannedValueServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Cue/__init__.py +0 -0
- dmxc_protobuf/Common/Types/Cuelist/CuelistGroupServiceTypes_pb2.py +52 -0
- dmxc_protobuf/Common/Types/Cuelist/CuelistGroupServiceTypes_pb2.pyi +101 -0
- dmxc_protobuf/Common/Types/Cuelist/CuelistGroupServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Cuelist/CuelistServiceTypes_pb2.py +92 -0
- dmxc_protobuf/Common/Types/Cuelist/CuelistServiceTypes_pb2.pyi +337 -0
- dmxc_protobuf/Common/Types/Cuelist/CuelistServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Cuelist/__init__.py +0 -0
- dmxc_protobuf/Common/Types/DMX/DMXInterfaceManagementTypes_pb2.py +90 -0
- dmxc_protobuf/Common/Types/DMX/DMXInterfaceManagementTypes_pb2.pyi +278 -0
- dmxc_protobuf/Common/Types/DMX/DMXInterfaceManagementTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/DMX/DMXServiceTypes_pb2.py +49 -0
- dmxc_protobuf/Common/Types/DMX/DMXServiceTypes_pb2.pyi +83 -0
- dmxc_protobuf/Common/Types/DMX/DMXServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/DMX/__init__.py +0 -0
- dmxc_protobuf/Common/Types/DependencyTypes_pb2.py +40 -0
- dmxc_protobuf/Common/Types/DependencyTypes_pb2.pyi +44 -0
- dmxc_protobuf/Common/Types/DependencyTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Device/DeviceServiceCRUDTypes_pb2.py +79 -0
- dmxc_protobuf/Common/Types/Device/DeviceServiceCRUDTypes_pb2.pyi +241 -0
- dmxc_protobuf/Common/Types/Device/DeviceServiceCRUDTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Device/DeviceServiceTypes_pb2.py +96 -0
- dmxc_protobuf/Common/Types/Device/DeviceServiceTypes_pb2.pyi +558 -0
- dmxc_protobuf/Common/Types/Device/DeviceServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Device/ProxyDeviceServiceTypes_pb2.py +45 -0
- dmxc_protobuf/Common/Types/Device/ProxyDeviceServiceTypes_pb2.pyi +59 -0
- dmxc_protobuf/Common/Types/Device/ProxyDeviceServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Device/__init__.py +0 -0
- dmxc_protobuf/Common/Types/ElectricityServiceTypes_pb2.py +63 -0
- dmxc_protobuf/Common/Types/ElectricityServiceTypes_pb2.pyi +118 -0
- dmxc_protobuf/Common/Types/ElectricityServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Executor/ExecutorServiceCRUDTypes_pb2.py +70 -0
- dmxc_protobuf/Common/Types/Executor/ExecutorServiceCRUDTypes_pb2.pyi +184 -0
- dmxc_protobuf/Common/Types/Executor/ExecutorServiceCRUDTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Executor/ExecutorServiceTypes_pb2.py +41 -0
- dmxc_protobuf/Common/Types/Executor/ExecutorServiceTypes_pb2.pyi +77 -0
- dmxc_protobuf/Common/Types/Executor/ExecutorServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Executor/__init__.py +0 -0
- dmxc_protobuf/Common/Types/Input/InputServiceCRUDTypes_pb2.py +101 -0
- dmxc_protobuf/Common/Types/Input/InputServiceCRUDTypes_pb2.pyi +389 -0
- dmxc_protobuf/Common/Types/Input/InputServiceCRUDTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Input/InputServiceTypes_pb2.py +67 -0
- dmxc_protobuf/Common/Types/Input/InputServiceTypes_pb2.pyi +207 -0
- dmxc_protobuf/Common/Types/Input/InputServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Input/MacroBoard/MacroBoardServiceCRUDTypes_pb2.py +58 -0
- dmxc_protobuf/Common/Types/Input/MacroBoard/MacroBoardServiceCRUDTypes_pb2.pyi +143 -0
- dmxc_protobuf/Common/Types/Input/MacroBoard/MacroBoardServiceCRUDTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Input/MacroBoard/MacroBoardServiceTypes_pb2.py +42 -0
- dmxc_protobuf/Common/Types/Input/MacroBoard/MacroBoardServiceTypes_pb2.pyi +53 -0
- dmxc_protobuf/Common/Types/Input/MacroBoard/MacroBoardServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Input/MacroBoard/__init__.py +0 -0
- dmxc_protobuf/Common/Types/Input/__init__.py +0 -0
- dmxc_protobuf/Common/Types/ItemListServiceTypes_pb2.py +58 -0
- dmxc_protobuf/Common/Types/ItemListServiceTypes_pb2.pyi +126 -0
- dmxc_protobuf/Common/Types/ItemListServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/LogServiceTypes_pb2.py +46 -0
- dmxc_protobuf/Common/Types/LogServiceTypes_pb2.pyi +76 -0
- dmxc_protobuf/Common/Types/LogServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Macro/MacroServiceCRUDTypes_pb2.py +50 -0
- dmxc_protobuf/Common/Types/Macro/MacroServiceCRUDTypes_pb2.pyi +80 -0
- dmxc_protobuf/Common/Types/Macro/MacroServiceCRUDTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Macro/MacroServiceTypes_pb2.py +40 -0
- dmxc_protobuf/Common/Types/Macro/MacroServiceTypes_pb2.pyi +42 -0
- dmxc_protobuf/Common/Types/Macro/MacroServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Macro/__init__.py +0 -0
- dmxc_protobuf/Common/Types/Master/MasterServiceCRUDTypes_pb2.py +57 -0
- dmxc_protobuf/Common/Types/Master/MasterServiceCRUDTypes_pb2.pyi +113 -0
- dmxc_protobuf/Common/Types/Master/MasterServiceCRUDTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Master/MasterServiceTypes_pb2.py +51 -0
- dmxc_protobuf/Common/Types/Master/MasterServiceTypes_pb2.pyi +93 -0
- dmxc_protobuf/Common/Types/Master/MasterServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Master/__init__.py +0 -0
- dmxc_protobuf/Common/Types/MonitoringServiceTypes_pb2.py +59 -0
- dmxc_protobuf/Common/Types/MonitoringServiceTypes_pb2.pyi +164 -0
- dmxc_protobuf/Common/Types/MonitoringServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/ParameterServiceTypes_pb2.py +60 -0
- dmxc_protobuf/Common/Types/ParameterServiceTypes_pb2.pyi +139 -0
- dmxc_protobuf/Common/Types/ParameterServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/PluginManagementTypes_pb2.py +44 -0
- dmxc_protobuf/Common/Types/PluginManagementTypes_pb2.pyi +52 -0
- dmxc_protobuf/Common/Types/PluginManagementTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/PositionMappingServiceTypes_pb2.py +53 -0
- dmxc_protobuf/Common/Types/PositionMappingServiceTypes_pb2.pyi +91 -0
- dmxc_protobuf/Common/Types/PositionMappingServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Preset/PresetServiceCRUDTypes_pb2.py +54 -0
- dmxc_protobuf/Common/Types/Preset/PresetServiceCRUDTypes_pb2.pyi +110 -0
- dmxc_protobuf/Common/Types/Preset/PresetServiceCRUDTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Preset/PresetServiceTypes_pb2.py +46 -0
- dmxc_protobuf/Common/Types/Preset/PresetServiceTypes_pb2.pyi +78 -0
- dmxc_protobuf/Common/Types/Preset/PresetServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Preset/__init__.py +0 -0
- dmxc_protobuf/Common/Types/ProgrammerServiceTypes_pb2.py +91 -0
- dmxc_protobuf/Common/Types/ProgrammerServiceTypes_pb2.pyi +414 -0
- dmxc_protobuf/Common/Types/ProgrammerServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Project/ProjectServiceTypes_pb2.py +129 -0
- dmxc_protobuf/Common/Types/Project/ProjectServiceTypes_pb2.pyi +611 -0
- dmxc_protobuf/Common/Types/Project/ProjectServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Project/__init__.py +0 -0
- dmxc_protobuf/Common/Types/RDM/RDMServiceCRUDTypes_pb2.py +40 -0
- dmxc_protobuf/Common/Types/RDM/RDMServiceCRUDTypes_pb2.pyi +32 -0
- dmxc_protobuf/Common/Types/RDM/RDMServiceCRUDTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/RDM/RDMServiceTypes_pb2.py +46 -0
- dmxc_protobuf/Common/Types/RDM/RDMServiceTypes_pb2.pyi +264 -0
- dmxc_protobuf/Common/Types/RDM/RDMServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/RDM/__init__.py +0 -0
- dmxc_protobuf/Common/Types/Resource/ResourceManagementCRUDTypes_pb2.py +49 -0
- dmxc_protobuf/Common/Types/Resource/ResourceManagementCRUDTypes_pb2.pyi +135 -0
- dmxc_protobuf/Common/Types/Resource/ResourceManagementCRUDTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Resource/ResourceManagementTypes_pb2.py +65 -0
- dmxc_protobuf/Common/Types/Resource/ResourceManagementTypes_pb2.pyi +173 -0
- dmxc_protobuf/Common/Types/Resource/ResourceManagementTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Resource/__init__.py +0 -0
- dmxc_protobuf/Common/Types/Settings/MainSwitchServiceTypes_pb2.py +42 -0
- dmxc_protobuf/Common/Types/Settings/MainSwitchServiceTypes_pb2.pyi +42 -0
- dmxc_protobuf/Common/Types/Settings/MainSwitchServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Settings/__init__.py +0 -0
- dmxc_protobuf/Common/Types/SettingsServiceTypes_pb2.py +63 -0
- dmxc_protobuf/Common/Types/SettingsServiceTypes_pb2.pyi +189 -0
- dmxc_protobuf/Common/Types/SettingsServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/StageView/StageViewServiceCRUDTypes_pb2.py +61 -0
- dmxc_protobuf/Common/Types/StageView/StageViewServiceCRUDTypes_pb2.pyi +165 -0
- dmxc_protobuf/Common/Types/StageView/StageViewServiceCRUDTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/StageView/StageViewServiceTypes_pb2.py +49 -0
- dmxc_protobuf/Common/Types/StageView/StageViewServiceTypes_pb2.pyi +103 -0
- dmxc_protobuf/Common/Types/StageView/StageViewServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/StageView/__init__.py +0 -0
- dmxc_protobuf/Common/Types/Timecode/TimecodeServiceCRUDTypes_pb2.py +110 -0
- dmxc_protobuf/Common/Types/Timecode/TimecodeServiceCRUDTypes_pb2.pyi +390 -0
- dmxc_protobuf/Common/Types/Timecode/TimecodeServiceCRUDTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Timecode/TimecodeServiceTypes_pb2.py +54 -0
- dmxc_protobuf/Common/Types/Timecode/TimecodeServiceTypes_pb2.pyi +184 -0
- dmxc_protobuf/Common/Types/Timecode/TimecodeServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/Timecode/__init__.py +0 -0
- dmxc_protobuf/Common/Types/UmbraServiceTypes_pb2.py +82 -0
- dmxc_protobuf/Common/Types/UmbraServiceTypes_pb2.pyi +274 -0
- dmxc_protobuf/Common/Types/UmbraServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/User/UserServiceCRUDTypes_pb2.py +49 -0
- dmxc_protobuf/Common/Types/User/UserServiceCRUDTypes_pb2.pyi +57 -0
- dmxc_protobuf/Common/Types/User/UserServiceCRUDTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/User/UserServiceTypes_pb2.py +52 -0
- dmxc_protobuf/Common/Types/User/UserServiceTypes_pb2.pyi +122 -0
- dmxc_protobuf/Common/Types/User/UserServiceTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/User/__init__.py +0 -0
- dmxc_protobuf/Common/Types/ValueTypes_pb2.py +97 -0
- dmxc_protobuf/Common/Types/ValueTypes_pb2.pyi +297 -0
- dmxc_protobuf/Common/Types/ValueTypes_pb2_grpc.py +24 -0
- dmxc_protobuf/Common/Types/__init__.py +0 -0
- dmxc_protobuf/Common/UmbraClientService_pb2.py +44 -0
- dmxc_protobuf/Common/UmbraClientService_pb2.pyi +7 -0
- dmxc_protobuf/Common/UmbraClientService_pb2_grpc.py +693 -0
- dmxc_protobuf/Common/__init__.py +0 -0
- dmxc_protobuf/Server/AffinityService_pb2.py +39 -0
- dmxc_protobuf/Server/AffinityService_pb2.pyi +6 -0
- dmxc_protobuf/Server/AffinityService_pb2_grpc.py +270 -0
- dmxc_protobuf/Server/AttachableService_pb2.py +39 -0
- dmxc_protobuf/Server/AttachableService_pb2.pyi +6 -0
- dmxc_protobuf/Server/AttachableService_pb2_grpc.py +356 -0
- dmxc_protobuf/Server/AudioService_pb2.py +39 -0
- dmxc_protobuf/Server/AudioService_pb2.pyi +6 -0
- dmxc_protobuf/Server/AudioService_pb2_grpc.py +270 -0
- dmxc_protobuf/Server/BackgroundTaskService_pb2.py +39 -0
- dmxc_protobuf/Server/BackgroundTaskService_pb2.pyi +6 -0
- dmxc_protobuf/Server/BackgroundTaskService_pb2_grpc.py +141 -0
- dmxc_protobuf/Server/BeatService_pb2.py +39 -0
- dmxc_protobuf/Server/BeatService_pb2.pyi +6 -0
- dmxc_protobuf/Server/BeatService_pb2_grpc.py +356 -0
- dmxc_protobuf/Server/CommandLineService_pb2.py +39 -0
- dmxc_protobuf/Server/CommandLineService_pb2.pyi +6 -0
- dmxc_protobuf/Server/CommandLineService_pb2_grpc.py +270 -0
- dmxc_protobuf/Server/CueService_pb2.py +39 -0
- dmxc_protobuf/Server/CueService_pb2.pyi +6 -0
- dmxc_protobuf/Server/CueService_pb2_grpc.py +356 -0
- dmxc_protobuf/Server/CueTriggerService_pb2.py +39 -0
- dmxc_protobuf/Server/CueTriggerService_pb2.pyi +6 -0
- dmxc_protobuf/Server/CueTriggerService_pb2_grpc.py +98 -0
- dmxc_protobuf/Server/CuelistGroupService_pb2.py +39 -0
- dmxc_protobuf/Server/CuelistGroupService_pb2.pyi +6 -0
- dmxc_protobuf/Server/CuelistGroupService_pb2_grpc.py +270 -0
- dmxc_protobuf/Server/CuelistService_pb2.py +39 -0
- dmxc_protobuf/Server/CuelistService_pb2.pyi +6 -0
- dmxc_protobuf/Server/CuelistService_pb2_grpc.py +572 -0
- dmxc_protobuf/Server/DMXInterfaceManagementService_pb2.py +39 -0
- dmxc_protobuf/Server/DMXInterfaceManagementService_pb2.pyi +6 -0
- dmxc_protobuf/Server/DMXInterfaceManagementService_pb2_grpc.py +743 -0
- dmxc_protobuf/Server/DMXService_pb2.py +39 -0
- dmxc_protobuf/Server/DMXService_pb2.pyi +6 -0
- dmxc_protobuf/Server/DMXService_pb2_grpc.py +313 -0
- dmxc_protobuf/Server/DeviceService_pb2.py +41 -0
- dmxc_protobuf/Server/DeviceService_pb2.pyi +8 -0
- dmxc_protobuf/Server/DeviceService_pb2_grpc.py +918 -0
- dmxc_protobuf/Server/ElectricityService_pb2.py +39 -0
- dmxc_protobuf/Server/ElectricityService_pb2.pyi +6 -0
- dmxc_protobuf/Server/ElectricityService_pb2_grpc.py +356 -0
- dmxc_protobuf/Server/ExecutorService_pb2.py +39 -0
- dmxc_protobuf/Server/ExecutorService_pb2.pyi +6 -0
- dmxc_protobuf/Server/ExecutorService_pb2_grpc.py +493 -0
- dmxc_protobuf/Server/FannedValueService_pb2.py +39 -0
- dmxc_protobuf/Server/FannedValueService_pb2.pyi +6 -0
- dmxc_protobuf/Server/FannedValueService_pb2_grpc.py +141 -0
- dmxc_protobuf/Server/InputService_pb2.py +39 -0
- dmxc_protobuf/Server/InputService_pb2.pyi +6 -0
- dmxc_protobuf/Server/InputService_pb2_grpc.py +1044 -0
- dmxc_protobuf/Server/ItemListService_pb2.py +39 -0
- dmxc_protobuf/Server/ItemListService_pb2.pyi +6 -0
- dmxc_protobuf/Server/ItemListService_pb2_grpc.py +356 -0
- dmxc_protobuf/Server/LogService_pb2.py +39 -0
- dmxc_protobuf/Server/LogService_pb2.pyi +6 -0
- dmxc_protobuf/Server/LogService_pb2_grpc.py +184 -0
- dmxc_protobuf/Server/MacroBoardService_pb2.py +39 -0
- dmxc_protobuf/Server/MacroBoardService_pb2.pyi +6 -0
- dmxc_protobuf/Server/MacroBoardService_pb2_grpc.py +442 -0
- dmxc_protobuf/Server/MacroService_pb2.py +39 -0
- dmxc_protobuf/Server/MacroService_pb2.pyi +6 -0
- dmxc_protobuf/Server/MacroService_pb2_grpc.py +313 -0
- dmxc_protobuf/Server/MainSwitchService_pb2.py +39 -0
- dmxc_protobuf/Server/MainSwitchService_pb2.pyi +6 -0
- dmxc_protobuf/Server/MainSwitchService_pb2_grpc.py +184 -0
- dmxc_protobuf/Server/MasterService_pb2.py +39 -0
- dmxc_protobuf/Server/MasterService_pb2.pyi +6 -0
- dmxc_protobuf/Server/MasterService_pb2_grpc.py +313 -0
- dmxc_protobuf/Server/MonitoringService_pb2.py +39 -0
- dmxc_protobuf/Server/MonitoringService_pb2.pyi +6 -0
- dmxc_protobuf/Server/MonitoringService_pb2_grpc.py +184 -0
- dmxc_protobuf/Server/ParameterService_pb2.py +39 -0
- dmxc_protobuf/Server/ParameterService_pb2.pyi +6 -0
- dmxc_protobuf/Server/ParameterService_pb2_grpc.py +227 -0
- dmxc_protobuf/Server/PluginManagementService_pb2.py +39 -0
- dmxc_protobuf/Server/PluginManagementService_pb2.pyi +6 -0
- dmxc_protobuf/Server/PluginManagementService_pb2_grpc.py +184 -0
- dmxc_protobuf/Server/PositionMappingService_pb2.py +39 -0
- dmxc_protobuf/Server/PositionMappingService_pb2.pyi +6 -0
- dmxc_protobuf/Server/PositionMappingService_pb2_grpc.py +270 -0
- dmxc_protobuf/Server/PresetService_pb2.py +40 -0
- dmxc_protobuf/Server/PresetService_pb2.pyi +7 -0
- dmxc_protobuf/Server/PresetService_pb2_grpc.py +443 -0
- dmxc_protobuf/Server/ProgrammerService_pb2.py +40 -0
- dmxc_protobuf/Server/ProgrammerService_pb2.pyi +7 -0
- dmxc_protobuf/Server/ProgrammerService_pb2_grpc.py +701 -0
- dmxc_protobuf/Server/ProjectService_pb2.py +39 -0
- dmxc_protobuf/Server/ProjectService_pb2.pyi +6 -0
- dmxc_protobuf/Server/ProjectService_pb2_grpc.py +829 -0
- dmxc_protobuf/Server/RDMService_pb2.py +39 -0
- dmxc_protobuf/Server/RDMService_pb2.pyi +6 -0
- dmxc_protobuf/Server/RDMService_pb2_grpc.py +313 -0
- dmxc_protobuf/Server/SettingsService_pb2.py +39 -0
- dmxc_protobuf/Server/SettingsService_pb2.pyi +6 -0
- dmxc_protobuf/Server/SettingsService_pb2_grpc.py +485 -0
- dmxc_protobuf/Server/StageviewService_pb2.py +39 -0
- dmxc_protobuf/Server/StageviewService_pb2.pyi +6 -0
- dmxc_protobuf/Server/StageviewService_pb2_grpc.py +270 -0
- dmxc_protobuf/Server/TimecodeService_pb2.py +39 -0
- dmxc_protobuf/Server/TimecodeService_pb2.pyi +6 -0
- dmxc_protobuf/Server/TimecodeService_pb2_grpc.py +1001 -0
- dmxc_protobuf/Server/UserService_pb2.py +41 -0
- dmxc_protobuf/Server/UserService_pb2.pyi +8 -0
- dmxc_protobuf/Server/UserService_pb2_grpc.py +490 -0
- dmxc_protobuf/Server/__init__.py +0 -0
- dmxc_protobuf/__init__.py +0 -0
- dmxc_protobuf/connection.py +583 -0
- dmxc_protobuf/events.py +74 -0
- dmxc_protobuf/extensions.py +204 -0
- dmxc_protobuf/i18n.py +47 -0
- dmxc_protobuf/net_constants.py +22 -0
- dmxc_protobuf/tools.py +11 -0
- dmxc_protobuf/udp.py +197 -0
- dmxcontrol3_network_interface-3.3.3.dist-info/METADATA +83 -0
- dmxcontrol3_network_interface-3.3.3.dist-info/RECORD +412 -0
- dmxcontrol3_network_interface-3.3.3.dist-info/WHEEL +4 -0
- dmxcontrol3_network_interface-3.3.3.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
"""Connection to an Umbra server (port of the C# ``UmbraConnectionClient``).
|
|
2
|
+
|
|
3
|
+
Uses ``grpc.aio``; all network methods are coroutines.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import asyncio
|
|
9
|
+
import enum
|
|
10
|
+
import inspect
|
|
11
|
+
import logging
|
|
12
|
+
import time
|
|
13
|
+
from dataclasses import dataclass, field
|
|
14
|
+
from typing import Any, Awaitable, Callable, Iterable, Optional, Protocol, Sequence, TypeVar
|
|
15
|
+
|
|
16
|
+
import grpc
|
|
17
|
+
import grpc.aio
|
|
18
|
+
|
|
19
|
+
from dmxc_protobuf import net_constants
|
|
20
|
+
from dmxc_protobuf.Common import UmbraClientService_pb2_grpc as svc
|
|
21
|
+
from dmxc_protobuf.Common.Types.BroadcastServiceTypes_pb2 import BroadcastMessage
|
|
22
|
+
from dmxc_protobuf.Common.Types.CommonTypes_pb2 import ConfirmedResponse, GetRequest
|
|
23
|
+
from dmxc_protobuf.Common.Types.UmbraServiceTypes_pb2 import (
|
|
24
|
+
ClientControlRequest,
|
|
25
|
+
ClientInfo,
|
|
26
|
+
ClientProgramInfo,
|
|
27
|
+
ELogoffReason_Unknown,
|
|
28
|
+
InformClientExistsRequest,
|
|
29
|
+
PingPong,
|
|
30
|
+
ReadyToWorkState,
|
|
31
|
+
SetNetworkPropertyRequest,
|
|
32
|
+
UmbraClientReadyToWorkNotification,
|
|
33
|
+
UmbraLoginRequest,
|
|
34
|
+
UmbraLoginResponse,
|
|
35
|
+
UmbraLogoffRequest,
|
|
36
|
+
)
|
|
37
|
+
from dmxc_protobuf.events import Event
|
|
38
|
+
from dmxc_protobuf.i18n import translatable as _t
|
|
39
|
+
from dmxc_protobuf.tools import contains_non_ascii_characters
|
|
40
|
+
from dmxc_protobuf.udp import UmbraDiscoveryBroadcastEventArgs
|
|
41
|
+
|
|
42
|
+
CALL_TIMEOUT = 3.0
|
|
43
|
+
PING_INTERVAL = 5.0
|
|
44
|
+
CLIENT_CONTROL_TIMEOUT = 0.5
|
|
45
|
+
|
|
46
|
+
Metadata = Sequence[tuple[str, str | bytes]]
|
|
47
|
+
T = TypeVar("T")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class ConnectionClientData(Protocol):
|
|
51
|
+
"""Supplies everything :class:`UmbraConnectionClient` needs. Plain attributes satisfy it."""
|
|
52
|
+
|
|
53
|
+
#: Channel to the Umbra server the client is connected to.
|
|
54
|
+
umbra_channel: grpc.aio.Channel
|
|
55
|
+
#: Metadata sent with every call.
|
|
56
|
+
host_metadata: Optional[Metadata]
|
|
57
|
+
client_program_info: ClientProgramInfo
|
|
58
|
+
clientname: str
|
|
59
|
+
network_id: str
|
|
60
|
+
|
|
61
|
+
def create_channel(self, host: str, port: int) -> grpc.aio.Channel:
|
|
62
|
+
"""Creates a channel to another (potential) Umbra server, used during discovery."""
|
|
63
|
+
...
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def create_umbra_channel(
|
|
67
|
+
host: str,
|
|
68
|
+
port: int = net_constants.UMBRA_LISTEN_PORT,
|
|
69
|
+
credentials: Optional[grpc.ChannelCredentials] = None,
|
|
70
|
+
) -> grpc.aio.Channel:
|
|
71
|
+
"""Creates an aio channel to an Umbra server with DMXControl's maximum message size."""
|
|
72
|
+
target = f"{host}:{port}"
|
|
73
|
+
options = [
|
|
74
|
+
("grpc.max_send_message_length", net_constants.MAX_MESSAGE_SIZE),
|
|
75
|
+
("grpc.max_receive_message_length", net_constants.MAX_MESSAGE_SIZE),
|
|
76
|
+
]
|
|
77
|
+
if credentials is None:
|
|
78
|
+
return grpc.aio.insecure_channel(target, options=options)
|
|
79
|
+
return grpc.aio.secure_channel(target, credentials, options=options)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class LoginException(Exception):
|
|
83
|
+
def __init__(self, message: str, return_code: int, session_id: Optional[str]) -> None:
|
|
84
|
+
super().__init__(message)
|
|
85
|
+
#: an ``UmbraLoginResponse.EReturnCode`` value
|
|
86
|
+
self.return_code = return_code
|
|
87
|
+
self.session_id = session_id
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@dataclass(frozen=True)
|
|
91
|
+
class ClientEventArgs:
|
|
92
|
+
client: ClientInfo
|
|
93
|
+
_login: Optional[bool] = None
|
|
94
|
+
|
|
95
|
+
@property
|
|
96
|
+
def login(self) -> bool:
|
|
97
|
+
return self._login is True
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
def logoff(self) -> bool:
|
|
101
|
+
return self._login is False
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
@dataclass(frozen=True)
|
|
105
|
+
class BroadcastEventArgs:
|
|
106
|
+
message: BroadcastMessage
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@dataclass
|
|
110
|
+
class ClientControlEventArgs:
|
|
111
|
+
"""Set ``processed``, ``ok`` and ``message`` within 500 ms to answer the request."""
|
|
112
|
+
|
|
113
|
+
request: ClientControlRequest
|
|
114
|
+
processed: bool = False
|
|
115
|
+
ok: bool = False
|
|
116
|
+
message: Optional[str] = field(default=None)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class EAutoconnectResult(enum.Enum):
|
|
120
|
+
OK = 0
|
|
121
|
+
Error = 1
|
|
122
|
+
NotReady = 2
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _code(e: BaseException) -> Optional[grpc.StatusCode]:
|
|
126
|
+
return e.code() if isinstance(e, grpc.RpcError) else None # type: ignore[attr-defined]
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class UmbraConnectionClient:
|
|
130
|
+
"""Logs in to Umbra, keeps the mandatory ping alive, and handles broadcasts, client
|
|
131
|
+
control requests and client change notifications.
|
|
132
|
+
|
|
133
|
+
Events (subscribe with ``+=``; handlers may be sync or async):
|
|
134
|
+
``umbra_user_changed(ClientEventArgs)``, ``broadcast_received(BroadcastEventArgs)``,
|
|
135
|
+
``client_control_request_received(ClientControlEventArgs)``, ``connection_lost()``.
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
def __init__(self, data_provider: Optional[ConnectionClientData] = None, logger: Optional[logging.Logger] = None) -> None:
|
|
139
|
+
self.data_provider: ConnectionClientData = data_provider # type: ignore[assignment]
|
|
140
|
+
self.logger = logger or logging.getLogger(__name__)
|
|
141
|
+
|
|
142
|
+
self.umbra_user_changed: Event[[ClientEventArgs]] = Event()
|
|
143
|
+
self.broadcast_received: Event[[BroadcastEventArgs]] = Event()
|
|
144
|
+
self.client_control_request_received: Event[[ClientControlEventArgs]] = Event()
|
|
145
|
+
self.connection_lost: Event[[]] = Event()
|
|
146
|
+
|
|
147
|
+
self.session_id: Optional[str] = None
|
|
148
|
+
self.connected_to_umbra: Optional[ClientProgramInfo] = None
|
|
149
|
+
|
|
150
|
+
self._tasks: set[asyncio.Task[Any]] = set()
|
|
151
|
+
self._generation = 0
|
|
152
|
+
self._broadcast_queue: Optional[asyncio.Queue[BroadcastMessage]] = None
|
|
153
|
+
self._auto_connection_in_progress = False
|
|
154
|
+
|
|
155
|
+
# ~~~~~~~~~~~~~~~~~~~ helpers ~~~~~~~~~~~~~~~~~~~
|
|
156
|
+
|
|
157
|
+
@property
|
|
158
|
+
def _md(self) -> Optional[Metadata]:
|
|
159
|
+
return self.data_provider.host_metadata
|
|
160
|
+
|
|
161
|
+
def _connected_stub(self) -> svc.ConnectedClientServiceStub:
|
|
162
|
+
return svc.ConnectedClientServiceStub(self.data_provider.umbra_channel)
|
|
163
|
+
|
|
164
|
+
def _spawn(self, coro: Awaitable[Any]) -> None:
|
|
165
|
+
task = asyncio.ensure_future(coro)
|
|
166
|
+
self._tasks.add(task)
|
|
167
|
+
task.add_done_callback(self._tasks.discard)
|
|
168
|
+
|
|
169
|
+
def _active(self, generation: int) -> bool:
|
|
170
|
+
return generation == self._generation
|
|
171
|
+
|
|
172
|
+
# ~~~~~~~~~~~~~~~~~~~ public API ~~~~~~~~~~~~~~~~~~~
|
|
173
|
+
|
|
174
|
+
async def connect(self, open_connections: bool = True) -> UmbraLoginResponse:
|
|
175
|
+
"""Logs in to Umbra. Raises :class:`LoginException` if the login fails."""
|
|
176
|
+
stub = svc.ClientServiceStub(self.data_provider.umbra_channel)
|
|
177
|
+
request = UmbraLoginRequest(client=self.data_provider.client_program_info)
|
|
178
|
+
start = time.monotonic()
|
|
179
|
+
try:
|
|
180
|
+
response: UmbraLoginResponse = await stub.Login(request, metadata=self._md, timeout=CALL_TIMEOUT)
|
|
181
|
+
except grpc.RpcError as e:
|
|
182
|
+
code = (
|
|
183
|
+
UmbraLoginResponse.AccessDenied
|
|
184
|
+
if _code(e) == grpc.StatusCode.PERMISSION_DENIED
|
|
185
|
+
else UmbraLoginResponse.Error
|
|
186
|
+
)
|
|
187
|
+
raise LoginException(e.details() or str(e), code, None) from e # type: ignore[attr-defined]
|
|
188
|
+
finally:
|
|
189
|
+
self.logger.debug("Login Call: %d ms", (time.monotonic() - start) * 1000)
|
|
190
|
+
|
|
191
|
+
if contains_non_ascii_characters(response.sessionId, True):
|
|
192
|
+
raise LoginException("Invalid SessionID", UmbraLoginResponse.Error, response.sessionId)
|
|
193
|
+
|
|
194
|
+
if response.returnCode not in (UmbraLoginResponse.NoError, UmbraLoginResponse.AlreadyLoggedIn):
|
|
195
|
+
raise LoginException(response.message, response.returnCode, response.sessionId)
|
|
196
|
+
|
|
197
|
+
self.session_id = response.sessionId
|
|
198
|
+
self.connected_to_umbra = response.umbraServer if response.HasField("umbraServer") else None
|
|
199
|
+
|
|
200
|
+
if open_connections:
|
|
201
|
+
self.open_connections_after_connect()
|
|
202
|
+
|
|
203
|
+
return response
|
|
204
|
+
|
|
205
|
+
async def report_ready_to_work(self, state: ReadyToWorkState) -> None:
|
|
206
|
+
request = UmbraClientReadyToWorkNotification(state=state)
|
|
207
|
+
try:
|
|
208
|
+
await self._connected_stub().ReportReadyToWork(request, metadata=self._md, timeout=CALL_TIMEOUT)
|
|
209
|
+
except Exception as e:
|
|
210
|
+
self.logger.debug("report_ready_to_work: %s", e, exc_info=True)
|
|
211
|
+
|
|
212
|
+
async def send_client_control_request(self, request: ClientControlRequest) -> Optional[ConfirmedResponse]:
|
|
213
|
+
"""Asks Umbra to forward a control request to another client. Returns None on failure."""
|
|
214
|
+
if request is None or not request.controlClientRuntimeId:
|
|
215
|
+
return None
|
|
216
|
+
|
|
217
|
+
cinfo = self.data_provider.client_program_info.clientInfo
|
|
218
|
+
if request.controlClientRuntimeId == cinfo.runtimeid:
|
|
219
|
+
raise ValueError("Cannot send a client control request to yourself")
|
|
220
|
+
|
|
221
|
+
request.source.CopyFrom(cinfo)
|
|
222
|
+
try:
|
|
223
|
+
return await self._connected_stub().ControlClient(request, metadata=self._md, timeout=CALL_TIMEOUT)
|
|
224
|
+
except Exception as e:
|
|
225
|
+
self.logger.debug("send_client_control_request: %s", e, exc_info=True)
|
|
226
|
+
return None
|
|
227
|
+
|
|
228
|
+
async def disconnect(self) -> None:
|
|
229
|
+
"""Logs off from Umbra and closes all streams."""
|
|
230
|
+
if self.session_id is not None:
|
|
231
|
+
stub = svc.ClientServiceStub(self.data_provider.umbra_channel)
|
|
232
|
+
request = UmbraLogoffRequest(client=self.data_provider.client_program_info)
|
|
233
|
+
try:
|
|
234
|
+
response = await stub.Logoff(request, metadata=self._md, timeout=CALL_TIMEOUT)
|
|
235
|
+
self.logger.info("Disconnected from Umbra Server: %s", response.bye)
|
|
236
|
+
except Exception as e:
|
|
237
|
+
self.logger.debug("Unable to logoff: %s", e, exc_info=True)
|
|
238
|
+
|
|
239
|
+
self.session_id = None
|
|
240
|
+
self.connected_to_umbra = None
|
|
241
|
+
await self._close_streams()
|
|
242
|
+
|
|
243
|
+
async def _close_streams(self) -> None:
|
|
244
|
+
self._generation += 1
|
|
245
|
+
self._broadcast_queue = None
|
|
246
|
+
tasks = list(self._tasks)
|
|
247
|
+
for t in tasks:
|
|
248
|
+
t.cancel()
|
|
249
|
+
await asyncio.gather(*tasks, return_exceptions=True)
|
|
250
|
+
|
|
251
|
+
def send_broadcast(self, m: BroadcastMessage) -> bool:
|
|
252
|
+
"""Queues a broadcast for all clients. Returns False if the broadcast stream is not open."""
|
|
253
|
+
if m is None or self._broadcast_queue is None:
|
|
254
|
+
return False
|
|
255
|
+
self._broadcast_queue.put_nowait(m)
|
|
256
|
+
return True
|
|
257
|
+
|
|
258
|
+
def open_connections_after_connect(self) -> None:
|
|
259
|
+
"""Opens the ping, client change, broadcast and client control streams.
|
|
260
|
+
Must be called from a running event loop."""
|
|
261
|
+
self._generation += 1
|
|
262
|
+
for t in list(self._tasks):
|
|
263
|
+
t.cancel()
|
|
264
|
+
gen = self._generation
|
|
265
|
+
|
|
266
|
+
start = time.monotonic()
|
|
267
|
+
self._spawn(self._run_ping(gen))
|
|
268
|
+
self._spawn(self._run_receive_user_changes(gen))
|
|
269
|
+
self._broadcast_queue = asyncio.Queue()
|
|
270
|
+
self._spawn(self._run_broadcast(gen, self._broadcast_queue))
|
|
271
|
+
self._spawn(self._run_control_client(gen))
|
|
272
|
+
self.logger.debug("OpenConnectionsAfterConnect: %d ms", (time.monotonic() - start) * 1000)
|
|
273
|
+
|
|
274
|
+
async def get_umbra_users(self) -> list[ClientInfo]:
|
|
275
|
+
"""The clients currently connected to Umbra (empty on failure)."""
|
|
276
|
+
stub = svc.DMXCNetServiceStub(self.data_provider.umbra_channel)
|
|
277
|
+
try:
|
|
278
|
+
res = await stub.GetUmbraNetworkInfo(GetRequest(), metadata=self._md, timeout=CALL_TIMEOUT)
|
|
279
|
+
return [c.clientInfo for c in res.connectedClients]
|
|
280
|
+
except Exception as e:
|
|
281
|
+
self.logger.error("%s", e, exc_info=True)
|
|
282
|
+
return []
|
|
283
|
+
|
|
284
|
+
async def get_client_program_info(self, runtime_id: str) -> Optional[ClientProgramInfo]:
|
|
285
|
+
try:
|
|
286
|
+
x = await self._connected_stub().GetClientProgramInfo(
|
|
287
|
+
GetRequest(requestId=runtime_id), metadata=self._md, timeout=CALL_TIMEOUT
|
|
288
|
+
)
|
|
289
|
+
return x.info if x.HasField("info") else None
|
|
290
|
+
except Exception:
|
|
291
|
+
return None
|
|
292
|
+
|
|
293
|
+
# ~~~~~~~~~~~~~~~~~~~ streams ~~~~~~~~~~~~~~~~~~~
|
|
294
|
+
|
|
295
|
+
def _handle_stream_end(self, name: str, gen: int, error: Optional[BaseException], restart: Callable[[], None]) -> None:
|
|
296
|
+
"""Ignored when closed or unavailable, restarted on UNKNOWN / CANCELLED, logged otherwise."""
|
|
297
|
+
if not self._active(gen) or error is None:
|
|
298
|
+
return
|
|
299
|
+
code = _code(error)
|
|
300
|
+
if code == grpc.StatusCode.UNAVAILABLE:
|
|
301
|
+
return
|
|
302
|
+
if code in (grpc.StatusCode.UNKNOWN, grpc.StatusCode.CANCELLED):
|
|
303
|
+
self.logger.debug("Unknown RpcError. Restarting %s.", name)
|
|
304
|
+
restart()
|
|
305
|
+
return
|
|
306
|
+
self.logger.error("%s failed: %s", name, error, exc_info=error)
|
|
307
|
+
|
|
308
|
+
async def _run_receive_user_changes(self, gen: int) -> None:
|
|
309
|
+
call = self._connected_stub().ReceiveClientChanges(GetRequest(), metadata=self._md)
|
|
310
|
+
error: Optional[BaseException] = None
|
|
311
|
+
try:
|
|
312
|
+
async for resp in call:
|
|
313
|
+
login: Optional[bool] = None
|
|
314
|
+
reason = resp.WhichOneof("reason")
|
|
315
|
+
if reason == "login":
|
|
316
|
+
if not resp.login:
|
|
317
|
+
self.logger.debug("Strange User Info call. Reason is Login, but Login is false???. Ignoring.")
|
|
318
|
+
continue
|
|
319
|
+
login = True
|
|
320
|
+
elif reason == "logoff":
|
|
321
|
+
if resp.logoff == ELogoffReason_Unknown:
|
|
322
|
+
self.logger.debug("Strange User Info call. Reason is Logoff, but value is unknown???. Ignoring.")
|
|
323
|
+
continue
|
|
324
|
+
login = False
|
|
325
|
+
|
|
326
|
+
if not resp.HasField("client") or not resp.client.HasField("clientInfo"):
|
|
327
|
+
self.logger.debug("Strange User Info call. No User provided. Ignoring.")
|
|
328
|
+
continue
|
|
329
|
+
|
|
330
|
+
self.umbra_user_changed.fire(ClientEventArgs(resp.client.clientInfo, login))
|
|
331
|
+
except asyncio.CancelledError:
|
|
332
|
+
call.cancel()
|
|
333
|
+
raise
|
|
334
|
+
except Exception as e:
|
|
335
|
+
error = e
|
|
336
|
+
self._handle_stream_end("ReceiveUserChanges", gen, error, lambda: self._spawn(self._run_receive_user_changes(gen)))
|
|
337
|
+
|
|
338
|
+
async def _run_ping(self, gen: int, retry_on_disconnect: bool = False) -> None:
|
|
339
|
+
call = self._connected_stub().Ping(metadata=self._md)
|
|
340
|
+
lock = asyncio.Lock()
|
|
341
|
+
name = self.data_provider.clientname
|
|
342
|
+
|
|
343
|
+
async def sender() -> None:
|
|
344
|
+
counter = 0
|
|
345
|
+
try:
|
|
346
|
+
while True:
|
|
347
|
+
counter += 1
|
|
348
|
+
async with lock:
|
|
349
|
+
await call.write(PingPong(requestCounter=counter, clientname=self.data_provider.clientname))
|
|
350
|
+
await asyncio.sleep(PING_INTERVAL)
|
|
351
|
+
except asyncio.CancelledError:
|
|
352
|
+
raise
|
|
353
|
+
except Exception:
|
|
354
|
+
pass # the reader sees the final status
|
|
355
|
+
|
|
356
|
+
send_task = asyncio.ensure_future(sender())
|
|
357
|
+
error: Optional[BaseException] = None
|
|
358
|
+
try:
|
|
359
|
+
async for pong in call:
|
|
360
|
+
retry_on_disconnect = False # a successful exchange: the next failure gets a retry again
|
|
361
|
+
name = self.data_provider.clientname
|
|
362
|
+
if pong.clientname != name:
|
|
363
|
+
pong.responder = name
|
|
364
|
+
async with lock:
|
|
365
|
+
await call.write(pong)
|
|
366
|
+
except asyncio.CancelledError:
|
|
367
|
+
send_task.cancel()
|
|
368
|
+
call.cancel()
|
|
369
|
+
raise
|
|
370
|
+
except Exception as e:
|
|
371
|
+
error = e
|
|
372
|
+
finally:
|
|
373
|
+
send_task.cancel()
|
|
374
|
+
|
|
375
|
+
if not self._active(gen):
|
|
376
|
+
return
|
|
377
|
+
call.cancel()
|
|
378
|
+
|
|
379
|
+
if retry_on_disconnect:
|
|
380
|
+
self.logger.warning("Connection to Umbra lost.")
|
|
381
|
+
self.connection_lost.fire()
|
|
382
|
+
return
|
|
383
|
+
|
|
384
|
+
code = _code(error) if error else grpc.StatusCode.OK
|
|
385
|
+
if code in (grpc.StatusCode.UNAVAILABLE, grpc.StatusCode.UNAUTHENTICATED):
|
|
386
|
+
self.logger.info("Ping unavailable, maybe connection to Umbra lost?")
|
|
387
|
+
elif code in (grpc.StatusCode.UNKNOWN, grpc.StatusCode.CANCELLED, grpc.StatusCode.OK):
|
|
388
|
+
self.logger.debug("Unknown RpcError. Restarting Ping.")
|
|
389
|
+
else:
|
|
390
|
+
self.logger.error("Ping failed: %s", error, exc_info=error)
|
|
391
|
+
self._spawn(self._run_ping(gen, True))
|
|
392
|
+
|
|
393
|
+
async def _run_broadcast(self, gen: int, queue: asyncio.Queue[BroadcastMessage]) -> None:
|
|
394
|
+
call = self._connected_stub().SendBroadcast(metadata=self._md)
|
|
395
|
+
|
|
396
|
+
async def sender() -> None:
|
|
397
|
+
try:
|
|
398
|
+
while True:
|
|
399
|
+
m = await queue.get()
|
|
400
|
+
await call.write(m)
|
|
401
|
+
except asyncio.CancelledError:
|
|
402
|
+
raise
|
|
403
|
+
except Exception:
|
|
404
|
+
pass # the reader sees the final status
|
|
405
|
+
|
|
406
|
+
send_task = asyncio.ensure_future(sender())
|
|
407
|
+
error: Optional[BaseException] = None
|
|
408
|
+
try:
|
|
409
|
+
async for bc in call:
|
|
410
|
+
self.broadcast_received.fire(BroadcastEventArgs(bc))
|
|
411
|
+
except asyncio.CancelledError:
|
|
412
|
+
send_task.cancel()
|
|
413
|
+
call.cancel()
|
|
414
|
+
raise
|
|
415
|
+
except Exception as e:
|
|
416
|
+
error = e
|
|
417
|
+
finally:
|
|
418
|
+
send_task.cancel()
|
|
419
|
+
|
|
420
|
+
restarted = False
|
|
421
|
+
|
|
422
|
+
def restart() -> None:
|
|
423
|
+
nonlocal restarted
|
|
424
|
+
restarted = True
|
|
425
|
+
# take over the messages that were not sent yet
|
|
426
|
+
self._spawn(self._run_broadcast(gen, queue))
|
|
427
|
+
|
|
428
|
+
self._handle_stream_end("Broadcast", gen, error, restart)
|
|
429
|
+
if not restarted and self._active(gen) and self._broadcast_queue is queue:
|
|
430
|
+
self._broadcast_queue = None
|
|
431
|
+
|
|
432
|
+
async def _run_control_client(self, gen: int) -> None:
|
|
433
|
+
call = self._connected_stub().ProcessClientControls(metadata=self._md)
|
|
434
|
+
error: Optional[BaseException] = None
|
|
435
|
+
try:
|
|
436
|
+
async for req in call:
|
|
437
|
+
args = ClientControlEventArgs(req)
|
|
438
|
+
handler_task = asyncio.ensure_future(self.client_control_request_received.fire_async(args))
|
|
439
|
+
done, _ = await asyncio.wait({handler_task}, timeout=CLIENT_CONTROL_TIMEOUT)
|
|
440
|
+
timeout = not done
|
|
441
|
+
|
|
442
|
+
if timeout:
|
|
443
|
+
message = _t("Timeout")
|
|
444
|
+
elif args.processed:
|
|
445
|
+
message = _t(args.message or "")
|
|
446
|
+
else:
|
|
447
|
+
message = _t("Not processed")
|
|
448
|
+
resp = ConfirmedResponse(
|
|
449
|
+
requestId=req.requestId,
|
|
450
|
+
message=message,
|
|
451
|
+
ok=not timeout and args.processed and args.ok,
|
|
452
|
+
)
|
|
453
|
+
await call.write(resp)
|
|
454
|
+
except asyncio.CancelledError:
|
|
455
|
+
call.cancel()
|
|
456
|
+
raise
|
|
457
|
+
except Exception as e:
|
|
458
|
+
error = e
|
|
459
|
+
self._handle_stream_end("ControlClient", gen, error, lambda: self._spawn(self._run_control_client(gen)))
|
|
460
|
+
|
|
461
|
+
# ~~~~~~~~~~~~~~~~~~~ discovery ~~~~~~~~~~~~~~~~~~~
|
|
462
|
+
|
|
463
|
+
async def process_discovery_broadcast(
|
|
464
|
+
self,
|
|
465
|
+
args: UmbraDiscoveryBroadcastEventArgs,
|
|
466
|
+
process_requests: Optional[Callable[[Sequence[SetNetworkPropertyRequest]], Any]],
|
|
467
|
+
autoconnect_function: Optional[Callable[[str, int], Awaitable[EAutoconnectResult]]],
|
|
468
|
+
local_ips: Iterable[str],
|
|
469
|
+
) -> None:
|
|
470
|
+
"""Handles an Umbra discovery broadcast.
|
|
471
|
+
|
|
472
|
+
Informs that Umbra that this client exists (passing any network property requests it
|
|
473
|
+
returns to ``process_requests``) and, if this client is not connected yet and the
|
|
474
|
+
network IDs match, calls ``autoconnect_function(host, port)`` for each Umbra IP until
|
|
475
|
+
one succeeds.
|
|
476
|
+
|
|
477
|
+
``local_ips`` are the local IP addresses including loopback; if they equal the Umbra's
|
|
478
|
+
IPs, localhost is tried first.
|
|
479
|
+
"""
|
|
480
|
+
dgram = args.broadcast
|
|
481
|
+
remote_address = args.end_point[0]
|
|
482
|
+
|
|
483
|
+
if not dgram.HasField("umbraServer") or not dgram.umbraServer.HasField("clientInfo"):
|
|
484
|
+
return
|
|
485
|
+
umbra = dgram.umbraServer.clientInfo
|
|
486
|
+
local_ip_set = set(local_ips)
|
|
487
|
+
loopback = "127.0.0.1"
|
|
488
|
+
|
|
489
|
+
async def do_try_all_ips(action: Callable[[str, int], Awaitable[tuple[Optional[bool], Optional[T]]]]) -> Optional[T]:
|
|
490
|
+
target = remote_address
|
|
491
|
+
to_try = list(dict.fromkeys(umbra.ips)) # ordered set
|
|
492
|
+
if set(to_try) == local_ip_set and loopback in to_try:
|
|
493
|
+
# same IPs mean running on the same computer, therefore trying localhost first
|
|
494
|
+
if self._auto_connection_in_progress:
|
|
495
|
+
self.logger.info(
|
|
496
|
+
"Same IP Addresses detected [%s], prefering Localhost to connect first", ", ".join(umbra.ips)
|
|
497
|
+
)
|
|
498
|
+
target = loopback
|
|
499
|
+
|
|
500
|
+
done: Optional[bool] = None
|
|
501
|
+
result: Optional[T] = None
|
|
502
|
+
if target in to_try:
|
|
503
|
+
to_try.remove(target)
|
|
504
|
+
done, result = await action(target, umbra.umbraPort)
|
|
505
|
+
else:
|
|
506
|
+
self.logger.warning(
|
|
507
|
+
"Received Umbra Broadcast from IP %s, using IP %s but that is not listed in Umbra IPs: [%s]",
|
|
508
|
+
remote_address, target, ", ".join(umbra.ips),
|
|
509
|
+
)
|
|
510
|
+
|
|
511
|
+
while done is None and to_try:
|
|
512
|
+
ip = to_try.pop(0)
|
|
513
|
+
done, result = await action(ip, umbra.umbraPort)
|
|
514
|
+
|
|
515
|
+
if done is None:
|
|
516
|
+
self.logger.warning("Unable to contact any of the Umbra %s IPs: [%s]", umbra.clientname, ", ".join(umbra.ips))
|
|
517
|
+
return result
|
|
518
|
+
|
|
519
|
+
async def inform_umbra_ask_for_actions(target: str, port: int) -> tuple[Optional[bool], Optional[ClientInfo]]:
|
|
520
|
+
channel: Optional[grpc.aio.Channel] = None
|
|
521
|
+
try:
|
|
522
|
+
channel = self.data_provider.create_channel(target, port)
|
|
523
|
+
stub = svc.DMXCNetServiceStub(channel)
|
|
524
|
+
a = InformClientExistsRequest(info=self.data_provider.client_program_info)
|
|
525
|
+
res = await stub.InformClientExists(a, metadata=self._md, timeout=CALL_TIMEOUT)
|
|
526
|
+
if len(res.requests) > 0 and process_requests is not None:
|
|
527
|
+
r = process_requests(list(res.requests))
|
|
528
|
+
if inspect.isawaitable(r):
|
|
529
|
+
await r
|
|
530
|
+
return True, (res.umbra.clientInfo if res.HasField("umbra") else None)
|
|
531
|
+
except grpc.RpcError as e:
|
|
532
|
+
code = _code(e)
|
|
533
|
+
if code == grpc.StatusCode.DEADLINE_EXCEEDED:
|
|
534
|
+
self.logger.debug("Timeout when connecting to Umbra %s @ %s", umbra.clientname, target)
|
|
535
|
+
elif code == grpc.StatusCode.UNAVAILABLE:
|
|
536
|
+
self.logger.info("Unable to connect to Umbra %s @ %s", umbra.clientname, target)
|
|
537
|
+
elif code != grpc.StatusCode.CANCELLED:
|
|
538
|
+
self.logger.debug("Unable to inform Source Umbra %s @ %s...", umbra.clientname, target, exc_info=True)
|
|
539
|
+
except Exception:
|
|
540
|
+
self.logger.debug("Unable to inform Source Umbra %s @ %s...", umbra.clientname, target, exc_info=True)
|
|
541
|
+
finally:
|
|
542
|
+
if channel is not None:
|
|
543
|
+
await channel.close()
|
|
544
|
+
return None, None
|
|
545
|
+
|
|
546
|
+
async def do_autoconnect(target: str, port: int) -> tuple[Optional[bool], None]:
|
|
547
|
+
assert autoconnect_function is not None
|
|
548
|
+
try:
|
|
549
|
+
erg = await autoconnect_function(target, umbra.umbraPort)
|
|
550
|
+
if erg == EAutoconnectResult.OK:
|
|
551
|
+
return True, None
|
|
552
|
+
if erg == EAutoconnectResult.NotReady:
|
|
553
|
+
return False, None
|
|
554
|
+
except LoginException as e:
|
|
555
|
+
self.logger.error("Unable to Login to Umbra Server: %s", e)
|
|
556
|
+
except asyncio.CancelledError:
|
|
557
|
+
self.logger.warning("Connect Request cancelled")
|
|
558
|
+
raise
|
|
559
|
+
except Exception as e:
|
|
560
|
+
self.logger.error("Exception when connecting to Umbra Server: %s", e)
|
|
561
|
+
return None, None
|
|
562
|
+
|
|
563
|
+
client_info = await do_try_all_ips(inform_umbra_ask_for_actions)
|
|
564
|
+
|
|
565
|
+
# are we already connected?
|
|
566
|
+
if self.session_id:
|
|
567
|
+
connected = self.connected_to_umbra
|
|
568
|
+
if connected is not None and umbra.runtimeid == connected.clientInfo.runtimeid and connected != dgram.umbraServer:
|
|
569
|
+
self.connected_to_umbra = dgram.umbraServer
|
|
570
|
+
return
|
|
571
|
+
|
|
572
|
+
if autoconnect_function is None:
|
|
573
|
+
return
|
|
574
|
+
|
|
575
|
+
nid = self.data_provider.network_id
|
|
576
|
+
unid = umbra.networkid if umbra.networkid.strip() else (client_info.networkid if client_info is not None else None)
|
|
577
|
+
|
|
578
|
+
if nid == unid and not self._auto_connection_in_progress:
|
|
579
|
+
try:
|
|
580
|
+
self._auto_connection_in_progress = True
|
|
581
|
+
await do_try_all_ips(do_autoconnect)
|
|
582
|
+
finally:
|
|
583
|
+
self._auto_connection_in_progress = False
|
dmxc_protobuf/events.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""A small multi-handler event, similar to C# events."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import inspect
|
|
7
|
+
import logging
|
|
8
|
+
from typing import Any, Awaitable, Callable, Generic, ParamSpec
|
|
9
|
+
|
|
10
|
+
P = ParamSpec("P")
|
|
11
|
+
|
|
12
|
+
_log = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Event(Generic[P]):
|
|
16
|
+
"""Handlers can be added with ``event += handler`` (or :meth:`subscribe`) and may be
|
|
17
|
+
plain functions or coroutine functions. Handler exceptions are logged, not raised."""
|
|
18
|
+
|
|
19
|
+
def __init__(self) -> None:
|
|
20
|
+
self._handlers: list[Callable[P, Any]] = []
|
|
21
|
+
self._pending: set[asyncio.Future[Any]] = set()
|
|
22
|
+
|
|
23
|
+
def subscribe(self, handler: Callable[P, Any]) -> Callable[P, Any]:
|
|
24
|
+
self._handlers.append(handler)
|
|
25
|
+
return handler
|
|
26
|
+
|
|
27
|
+
def unsubscribe(self, handler: Callable[P, Any]) -> None:
|
|
28
|
+
if handler in self._handlers:
|
|
29
|
+
self._handlers.remove(handler)
|
|
30
|
+
|
|
31
|
+
def __iadd__(self, handler: Callable[P, Any]) -> Event[P]:
|
|
32
|
+
self.subscribe(handler)
|
|
33
|
+
return self
|
|
34
|
+
|
|
35
|
+
def __isub__(self, handler: Callable[P, Any]) -> Event[P]:
|
|
36
|
+
self.unsubscribe(handler)
|
|
37
|
+
return self
|
|
38
|
+
|
|
39
|
+
def clear(self) -> None:
|
|
40
|
+
self._handlers.clear()
|
|
41
|
+
|
|
42
|
+
def __len__(self) -> int:
|
|
43
|
+
return len(self._handlers)
|
|
44
|
+
|
|
45
|
+
def fire(self, *args: P.args, **kwargs: P.kwargs) -> None:
|
|
46
|
+
"""Calls all handlers; results of coroutine handlers are scheduled, not awaited."""
|
|
47
|
+
for h in list(self._handlers):
|
|
48
|
+
try:
|
|
49
|
+
r = h(*args, **kwargs)
|
|
50
|
+
if inspect.isawaitable(r):
|
|
51
|
+
fut = asyncio.ensure_future(r)
|
|
52
|
+
self._pending.add(fut)
|
|
53
|
+
fut.add_done_callback(self._done)
|
|
54
|
+
except Exception:
|
|
55
|
+
_log.exception("Event handler failed")
|
|
56
|
+
|
|
57
|
+
async def fire_async(self, *args: P.args, **kwargs: P.kwargs) -> None:
|
|
58
|
+
"""Calls all handlers and awaits the coroutine ones."""
|
|
59
|
+
awaitables: list[Awaitable[Any]] = []
|
|
60
|
+
for h in list(self._handlers):
|
|
61
|
+
try:
|
|
62
|
+
r = h(*args, **kwargs)
|
|
63
|
+
if inspect.isawaitable(r):
|
|
64
|
+
awaitables.append(r)
|
|
65
|
+
except Exception:
|
|
66
|
+
_log.exception("Event handler failed")
|
|
67
|
+
for res in await asyncio.gather(*awaitables, return_exceptions=True):
|
|
68
|
+
if isinstance(res, Exception):
|
|
69
|
+
_log.error("Event handler failed", exc_info=res)
|
|
70
|
+
|
|
71
|
+
def _done(self, fut: asyncio.Future[Any]) -> None:
|
|
72
|
+
self._pending.discard(fut)
|
|
73
|
+
if not fut.cancelled() and fut.exception() is not None:
|
|
74
|
+
_log.error("Event handler failed", exc_info=fut.exception())
|