How to use _subscribed_message_type method in lisa

Best Python code snippet using lisa_python

notifier.py

Source:notifier.py Github

copy

Full Screen

...21 or do finalize work, like save to a file.22 Even failed, this method will be called.23 """24 pass25 def _subscribed_message_type(self) -> List[Type[MessageBase]]:26 """27 Specify which message types want to be subscribed.28 Other types won't be passed in.29 """30 raise NotImplementedError("must specify supported message types")31 def _received_message(self, message: MessageBase) -> None:32 """33 Called by notifier, when a subscribed message happens.34 """35 raise NotImplementedError36 def _initialize(self, *args: Any, **kwargs: Any) -> None:37 """38 initialize is optional39 """40 pass41_notifiers: List[Notifier] = []42_messages: Dict[type, List[Notifier]] = {}43# prevent concurrent message conflict.44_message_queue: List[MessageBase] = []45_message_queue_lock = threading.Lock()46_notifying_lock = threading.Lock()47_system_notifiers = [constants.NOTIFIER_CONSOLE, constants.NOTIFIER_FILE]48def initialize(runbooks: List[schema.Notifier]) -> None:49 factory = subclasses.Factory[Notifier](Notifier)50 log = _get_init_logger()51 # add system notifiers to provide troubleshooting information52 names = (x.type.lower() for x in runbooks)53 for system_notifier in _system_notifiers:54 if system_notifier not in names:55 runbooks.append(schema.Notifier(type=system_notifier))56 for runbook in runbooks:57 if not runbook.enabled:58 log.debug(f"skipped notifier [{runbook.type}], because it's not enabled.")59 continue60 notifier = factory.create_by_runbook(runbook=runbook)61 register_notifier(notifier)62def register_notifier(notifier: Notifier) -> None:63 """64 register internal notifiers65 """66 notifier.initialize()67 _notifiers.append(notifier)68 subscribed_message_types: List[69 Type[MessageBase]70 ] = notifier._subscribed_message_type()71 for message_type in subscribed_message_types:72 registered_notifiers = _messages.get(message_type, [])73 registered_notifiers.append(notifier)74 _messages[message_type] = registered_notifiers75 log = _get_init_logger()76 log.debug(77 f"registered [{notifier.type_name()}] "78 f"on messages: {[x.type for x in subscribed_message_types]}"79 )80def notify(message: MessageBase) -> None:81 message.time = datetime.utcnow()82 # to make sure message get order as possible, use a queue to hold messages.83 with _message_queue_lock:84 _message_queue.append(message)...

Full Screen

Full Screen

file.py

Source:file.py Github

copy

Full Screen

...28 simplify_message(message)29 # write every time to refresh the content immediately.30 with open(self._file_path, "a") as f:31 f.write(f"{datetime.now():%Y-%m-%d %H:%M:%S.%ff}: {message}\n")32 def _subscribed_message_type(self) -> List[Type[messages.MessageBase]]:33 return [messages.MessageBase]34 def _initialize(self, *args: Any, **kwargs: Any) -> None:35 runbook = cast(ConsoleSchema, self.runbook)...

Full Screen

Full Screen

console.py

Source:console.py Github

copy

Full Screen

...27 self._log.log(28 getattr(logging, self._log_level),29 f"received message [{message.type}]: {message}",30 )31 def _subscribed_message_type(self) -> List[Type[messages.MessageBase]]:32 return [messages.MessageBase]33 def _initialize(self, *args: Any, **kwargs: Any) -> None:34 runbook = cast(ConsoleSchema, self.runbook)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful