Best Python code snippet using autotest_python
mail.py
Source:mail.py  
...139        """140        Send an email to this grid admin.141        """142        self.send(self.grid_admin_email, subject, body)143    def enqueue_admin(self, subject, message):144        """145        Enqueue an email to the test grid admin.146        """147        if not self.grid_admin_email:148            return149        body = 'Subject: ' + subject + '\n'150        body += "%s / %s / %s\n%s" % (socket.gethostname(),151                                      os.getpid(),152                                      time.strftime("%X %x"), message)153        self.email_queue.append(body)154    def enqueue_exception_admin(self, reason):155        """156        Enqueue an email containing an exception to the test grid admin.157        """158        logging.exception(reason)159        message = "EXCEPTION: %s\n%s" % (reason, traceback.format_exc())160        self.enqueue_admin("Exception on module %s" %161                           self.module, message)162    def send_queued_admin(self):163        """164        Send all queued emails to the test grid admin.165        """166        if not self.email_queue:167            return168        subject = ('Notifications (%s) from host: %s' %169                   (self.module, socket.gethostname()))170        separator = '\n' + '-' * 40 + '\n'171        body = separator.join(self.email_queue)172        self.send_admin(subject, body)173        # Reset the email queue.174        self.email_queue = []...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!!
