Best Python code snippet using slash
notifications.py
Source:notifications.py  
...142    def _slack_notifier(self, message):143        slack_config = config.root.plugin_config.notifications.slack144        if (slack_config.url is None) or (slack_config.channel is None):145            return146        color = '#439FE0' if message.is_pdb else ('good' if self._finished_successfully() else 'danger')147        kwargs = {148            'attachments': [{149                'title': message.get_title(),150                'fallback': 'Session {session_id} {result}'.format(**message.kwargs),151                'text': message.get_short_message(),152                'color': color,153                }],154            'channel': slack_config.channel,155            'username': slack_config.from_user,156            'icon_url': _SLASH_ICON,157            }158        _post_request(slack_config.url, json=kwargs)159    def _finished_successfully(self):160        return session.results.is_success(allow_skips=True)161    def _get_message(self, short_message, is_pdb):162        result_str = 'entered PDB' if is_pdb else ("Succeeded" if self._finished_successfully() else "Failed")163        kwargs = {164            'session_id': session.id,165            'host_name': session.host_name,166            'full_name': 'N/A',167            'duration': str(datetime.timedelta(seconds=session.duration)).partition('.')[0],168            'result': result_str,169            'success': self._finished_successfully(),170            'results_summary': repr(session.results).replace('<', '').replace('>', ''),171            'total_num_tests': session.results.get_num_results(),172            'non_successful_tests': session.results.get_num_errors() + session.results.get_num_failures(),173        }174        backslash_plugin = slash.plugins.manager.get_active_plugins().get('backslash')175        if backslash_plugin and backslash_plugin.session:176            config.root.plugin_config.notifications.email.to_list.append(backslash_plugin.session.user_email)177            url = backslash_plugin.webapp_url + 'sessions/{}'.format(session.id)178            kwargs['backslash_link'] = url179            kwargs['full_name'] = backslash_plugin.session.user_display_name180            session_info = 'Backslash: {backslash_link}'181        else:182            session_info = 'Session ID: {session_id}'183        short_message += "\n\n" + session_info184        title = "Slash Session on {host_name} has {result}".format(**kwargs)185        kwargs['title'] = title186        return Message(title, short_message, kwargs, is_pdb)187    def entering_debugger(self, exc_info):188        if not self.current_config.notify_on_pdb:189            return190        self._notify_all(short_message=_escape_format(repr(exc_info[1])), is_pdb=True)191    def session_end(self):192        if session.duration < self.current_config.notification_threshold:193            return194        if self._finished_successfully() and self.current_config.notify_only_on_failures:195            return196        self._notify_all(short_message='{results_summary}', is_pdb=False)197    def _notify_all(self, short_message, is_pdb):198        message = self._get_message(short_message, is_pdb)199        hooks.prepare_notification(message=message) # pylint: disable=no-member200        this_config = config.get_path('plugin_config.notifications')201        for notifier_name, notifier_func in self._notifiers.items():202            if not this_config[notifier_name]['enabled']:203                continue204            with handling_exceptions(swallow=True):205                notifier_func(message)206def _escape_format(s):...__init__.py
Source:__init__.py  
...44        t = self.missing_since[task_dir]45        if t == None:46            return False47        return time.time() - t > 548    def _finished_successfully(self, run_id, task_dir):49        if not (task_dir in self.finished_successfully) and flock.finished_successfully(run_id, task_dir):50            self.finished_successfully.add(task_dir)51        return task_dir in self.finished_successfully52    def get_status(self, run_id, external_ids, queued_job_states, task_dir, job_deps):53        assert type(queued_job_states) == dict54        if self._finished_successfully(run_id, task_dir):55            return flock.FINISHED56        if task_dir in external_ids:57            lsf_id = external_ids[task_dir]58            if lsf_id in queued_job_states:59                self.update_failure(task_dir, True)60                return queued_job_states[lsf_id]61            else:62                self.update_failure(task_dir, False)63                if self.definitely_failed(task_dir):64                    return flock.FAILED65                else:66                    return flock.UNKNOWN67        else:68            all_deps_met = True...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
