How to use _add_notifier method in Slash

Best Python code snippet using slash

asyncio_qt.py

Source:asyncio_qt.py Github

copy

Full Screen

...110 self.args = args111 def call(self):112 self.callback(*self.args)113 def add_reader(self, fd, callback, *args):114 self._add_notifier(QtCore.QSocketNotifier.Read, self._readers,115 fd, callback, args)116 def _add_notifier(self, notifier_type, mapping,117 fd, callback, args):118 if fd in mapping:119 notifier = mapping[fd]120 notifier.callback = callback121 notifier.args = args122 notifier.qnotifier.setEnabled(True)123 else:124 notifier = self._Notifier(125 QtCore.QSocketNotifier(126 fd, notifier_type),127 callback, args)128 mapping[fd] = notifier129 notifier.qnotifier.activated.connect(notifier.call)130 def remove_reader(self, fd):131 assert fd in self._readers132 self._readers[fd].qnotifier.setEnabled(False)133 def add_writer(self, fd, callback, *args):134 self._add_notifier(QtCore.QSocketNotifier.Write, self._writers,135 fd, callback, args)136 def remove_writer(self, fd):137 assert fd in self._writers138 self._writers[fd].qnotifier.setEnabled(False)139 def add_exception(self, fd, callback, *args):140 self._add_notifier(QtCore.QSocketNotifier.Exception, self._exceptions,141 fd, callback, args)142 def remove_exception(self, fd):143 assert fd in self._exceptions144 self._exceptions[fd].qnotifier.setEnabled(False)145 @asyncio.coroutine146 def sock_recv(self, sock, nbytes):147 assert sock.gettimeout() == 0.0148 event = asyncio.Event()149 try:150 self.add_reader(sock.fileno(), event.set)151 yield From(event.wait())152 finally:153 self.remove_reader(sock.fileno())154 data = sock.recv(nbytes)...

Full Screen

Full Screen

notifications.py

Source:notifications.py Github

copy

Full Screen

...75 "notification_threshold": 5,76 "notify_only_on_failures": False // Cmdline(on='--notify-only-on-failures'),77 "notify_on_pdb": True,78 }79 self._add_notifier(self._prowl_notifier, 'prowl', {'api_key': None, 'enabled': True})80 self._add_notifier(self._nma_notifier, 'nma', {'api_key': None, 'enabled': True})81 self._add_notifier(self._pushbullet_notifier, 'pushbullet', {'api_key': None, 'enabled': True})82 self._add_notifier(self._email_notifier, 'email', {83 'from_email': 'Slash <noreply@getslash.github.io>',84 'smtp_server': None,85 'to_list': [] // Cmdline(append='--email-to', metavar='ADDRESS'),86 'cc_list': []87 })88 self._add_notifier(self._slack_notifier, 'slack', {'url': None, 'channel': None, 'from_user': 'slash-bot'})89 def get_name(self):90 return 'notifications'91 def get_default_config(self):92 return self._basic_config93 def _add_notifier(self, func, name, conf_dict=None):94 self._notifiers[name] = func95 if not conf_dict:96 conf_dict = {}97 assert isinstance(conf_dict, dict)98 conf_dict.setdefault('enabled', False)99 conf_dict['enabled'] //= Cmdline(on='--notify-{}'.format(name))100 self._basic_config[name] = conf_dict101 def _get_from_config_with_legacy(self, notifier_name, legacy_name, new_name):102 this_config = config.get_path('plugin_config.notifications')103 value = this_config[legacy_name]104 if value:105 warn_deprecation('{} is depreacted. use {}.{} instead'.format(legacy_name, notifier_name, new_name))106 else:107 value = this_config[notifier_name][new_name]...

Full Screen

Full Screen

traits.py

Source:traits.py Github

copy

Full Screen

...46 def _handler_wrapper(self, handler):47 def f(*args, **kwargs):48 return handler(self, *args, **kwargs)49 return f50 def _add_notifier(self, handler_name, handler, pattern, filters=None):51 if filters:52 obs = self._subject.pipe(*filters)53 else:54 obs = self._subject.pipe(55 ops.filter(56 lambda value: re.fullmatch(pattern, value["name"])57 and value["new"] != value["old"]58 ),59 )60 obs.subscribe(on_next=self._handler_wrapper(handler))61 if handler_name in self._observers:62 self._observers[handler_name].append(obs)63 else:64 self._observers[handler_name] = [obs]65 def observe(self, handler_name, handler, pattern, filters=None, split_notifiers=True):66 if split_notifiers:67 names = [name for name in self._observables if re.fullmatch(pattern, name)]68 for name in names:69 self._add_notifier(handler_name, handler, name, filters)70 else:71 self._add_notifier(handler_name, handler, pattern, filters)72 def _notify(self, name, old, new):73 self._subject.on_next(dict(name=name, new=new, old=old))74 def __setattr__(self, name, value):75 try:76 old = super().__getattribute__(name)77 super().__setattr__(name, value)78 self._notify(name, old, value)79 except AttributeError:80 object.__setattr__(self, name, value)81class Trait(FieldInfo):82 def tag(self, **kwargs) -> "Trait":83 self.extra.update(**kwargs)...

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 Slash 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