VirtualBox

Changeset 76625 in vbox for trunk/src/VBox/ValidationKit


Ignore:
Timestamp:
Jan 3, 2019 5:24:36 PM (6 years ago)
Author:
vboxsync
Message:

vsheriff: Quick review of sendEmailAlert (formerly emailAlert) to make recent pylint happy. Fixed inconsistent return value, with rcExit being undefined in the success code path.

Location:
trunk/src/VBox/ValidationKit/testmanager
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testmanager/batch/virtual_test_sheriff.py

    r76553 r76625  
    367367        return rcExit;
    368368
    369     def emailAlert(self, uidAuthor, sBodyText):
    370         asEmailList = [];
     369    def sendEmailAlert(self, uidAuthor, sBodyText):
     370        """
     371        Sends email alert.
     372        """
    371373
    372374        # Get author email
     
    378380            sFrom = g_ksAlertFrom;
    379381
     382        # Gather recipient list.
     383        asEmailList = [];
    380384        for sUser in g_asAlertList:
    381385            self.oDb.execute('SELECT sEmail FROM Users WHERE sUsername=%s', (sUser,));
    382386            sEmail = self.oDb.fetchOne();
    383             if sEmail is None:
    384                 # No address to send an alert.
    385                 return;
    386             asEmailList.append(sEmail[0]);
    387 
     387            if sEmail:
     388                asEmailList.append(sEmail[0]);
     389        if not asEmailList:
     390            return self.eprint('No email addresses to send alter to!');
     391
     392        # Compose the message.
    388393        oMsg = MIMEMultipart();
    389394        oMsg['From'] = sFrom;
     
    392397        oMsg.attach(MIMEText(sBodyText, 'plain'))
    393398
     399        # Try send it.
    394400        try:
    395401            oSMTP = smtplib.SMTP(g_ksSmtpHost, g_kcSmtpPort);
     
    397403            oSMTP.quit()
    398404        except smtplib.SMTPException as oXcpt:
    399             rcExit = self.eprint('Failed to send mail: %s' % (oXcpt,));
    400 
    401         return rcExit;
    402 
     405            return self.eprint('Failed to send mail: %s' % (oXcpt,));
     406
     407        return 0;
    403408
    404409    def badTestBoxManagement(self):
     
    529534                sComment = u'Reset testbox #%u (%s) - iRC=%u sStduot=%s' % ( idTestBox, oTestBox.sName, iRC, sStdout);
    530535                self.vprint(sComment);
    531                 self.emailAlert(self.uidSelf, sComment);
     536                self.sendEmailAlert(self.uidSelf, sComment);
    532537
    533538            except Exception as oXcpt:
  • trunk/src/VBox/ValidationKit/testmanager/config.py

    r76553 r76625  
    194194g_kcSmtpPort            = 25;
    195195## Default email 'From' for email alert.
    196 g_ksAlertFrom           = 'vs[email protected]';
     196g_ksAlertFrom           = 'vsh[email protected]';
    197197## Subject for email alert.
    198 g_ksAlertSubject        = 'Virtual Sheriff alert';
     198g_ksAlertSubject        = 'Virtual Test Sheriff Alert';
    199199## List of users to send alerts.
    200200g_asAlertList           = ['lelik', 'werner'];
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette