Changeset 607 for branches


Ignore:
Timestamp:
Oct 14, 2007 9:51:11 PM (12 years ago)
Author:
jpfasano
Message:

modified functions for sending email. Took the one function and made 2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/testScripts/nightlyBuild.py

    r606 r607  
    4848#                 project manager.
    4949#----------------------------------------------------------------------
    50 SMTP_SERVER_NAME = 'outgoing.verizon.net'
    51 SMTP_SERVER_PORT = 25
    52 SMTP_SSL_SERVER = 0
    53 SMTP_USER_NAME = 'jpfasano'
    54 
    55 #SMTP_SERVER_NAME = 'smtp.gmail.com'
    56 #SMTP_SERVER_PORT = 587
    57 #SMTP_SSL_SERVER = 1
    58 #SMTP_USER_NAME = 'jpfasano _AT_ gmail _DOT_ com'
     50#SMTP_SERVER_NAME = 'outgoing.verizon.net'
     51#SMTP_SERVER_PORT = 25
     52#SMTP_SSL_SERVER = 0
     53#SMTP_USER_NAME = 'jpfasano'
     54
     55SMTP_SERVER_NAME = 'smtp.gmail.com'
     56SMTP_SERVER_PORT = 587
     57SMTP_SSL_SERVER = 1
     58SMTP_USER_NAME = 'jpfasano _AT_ gmail _DOT_ com'
    5959SMTP_PASSWORD_FILENAME = '/home/jp/bin/smtpPwFile'
    6060
    6161SENDER_EMAIL_ADDR='jpfasano _AT_ verizon _DOT_ net'
    62 #SENDER_EMAIL_ADDR='jpfasano _AT_ gmail _DOT_ com'
    6362MY_EMAIL_ADDR='jpfasano _AT_ us _DOT_ ibm _DOT_ com'
    6463SEND_MAIL_TO_PROJECT_MANAGER=0
     
    7069#----------------------------------------------------------------------
    7170PROJECTS = ['CoinUtils','DyLP','Clp','SYMPHONY','Vol','Osi','Cgl','Cbc','Ipopt','OS','CppAD']
    72 PROJECTS = ['CppAD']
     71#PROJECTS = ['CppAD']
    7372
    7473#----------------------------------------------------------------------
     
    126125
    127126#------------------------------------------------------------------------
    128 # Function to send an email message
    129 #------------------------------------------------------------------------
    130 def sendmail(project,cmdMsgs,cmd):
     127# Send email typically about an error.
     128#  project: coin project name
     129#  cmd: command being exucuted. perhaps: "svn update", "./configure",
     130#       "make".
     131#  cmdMsgs: the messages generated by cmd.  This will typically contain
     132#       errors issued by cmd.
     133#------------------------------------------------------------------------
     134def sendEmailCmdMsgs(project,cmdMsgs,cmd):
    131135  curDir = os.getcwd()
     136 
     137  toAddrs = [unscrambleEmailAddress(MY_EMAIL_ADDR)]
     138  if PROJECT_EMAIL_ADDRS.has_key(project) and SEND_MAIL_TO_PROJECT_MANAGER:
     139    toAddrs.append(unscrambleEmailAddress(PROJECT_EMAIL_ADDRS[project]))
     140
     141  subject = project + " build problem when running '" + cmd +"'"
     142
     143  emailMsg  = "'" + cmd + "' from directory " + curDir + " failed.\n\n"
     144  emailMsg += "'" + cmd + "' messages are:\n"
     145  emailMsg += cmdMsgs
     146  sendEmail(toAddrs,subject,emailMsg)
     147  writeLogMessage( "  email sent regarding "+project+" running '"+cmd+"'" )
     148
     149#------------------------------------------------------------------------
     150# Send email
     151#------------------------------------------------------------------------
     152def sendEmail(toAddrs,subject,message):
     153
     154  sender = unscrambleEmailAddress(SENDER_EMAIL_ADDR) 
     155  msgWHeader = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n"
     156       % (sender, ", ".join(toAddrs), subject))
     157  msgWHeader += message
    132158 
    133159  # Get smpt server password
     
    140166    print cmdMsgs
    141167    sys.exit(1)
    142   sender = unscrambleEmailAddress(SENDER_EMAIL_ADDR)
    143   toAddrs = [unscrambleEmailAddress(MY_EMAIL_ADDR)]
    144   if PROJECT_EMAIL_ADDRS.has_key(project) and SEND_MAIL_TO_PROJECT_MANAGER:
    145     toAddrs.append(unscrambleEmailAddress(PROJECT_EMAIL_ADDRS[project]))
     168   
    146169  session = smtplib.SMTP(SMTP_SERVER_NAME,SMTP_SERVER_PORT)
    147170  #session.set_debuglevel(1)
     
    149172    session.ehlo('x')
    150173    session.starttls()
    151     session.ehlo('x')
    152  
     174    session.ehlo('x') 
    153175  session.login(unscrambleEmailAddress(SMTP_USER_NAME),smtppass)
    154 
    155   subject = project + " build problem when running '" + cmd +"'"
    156   msgWHeader = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n"
    157        % (sender, ", ".join(toAddrs), subject))
    158   msgWHeader += "'" + cmd + "' from directory " + curDir + " failed.\n\n"
    159   msgWHeader += "'" + cmd + "' messages are:\n"
    160   msgWHeader += cmdMsgs
    161176
    162177  rc = session.sendmail(sender,toAddrs,msgWHeader)
     
    164179    writeLogMessage( 'session.sendmail rc='  )
    165180    writeLogMessage( rc )
    166   writeLogMessage( "  email sent regarding "+project+" running '"+cmd+"'" )
    167181  session.quit()
    168182
     
    217231  rc=commands.getstatusoutput(svnCmd)
    218232  if rc[0] != 0 :
    219     sendmail(project,rc[1],svnCmd)
     233    sendEmailCmdMsgs(project,rc[1],svnCmd)
    220234    retVal='Error'
    221235  return retVal
     
    305319      error_msg += logFilePtr.read()
    306320      logFilePtr.close()
    307     sendmail(p,error_msg,configCmd)
     321    sendEmailCmdMsgs(p,error_msg,configCmd)
    308322    continue
    309323
     
    316330  # Check if make worked
    317331  if rc[0] != 0 :
    318     sendmail(p,rc[1],'make')
     332    sendEmailCmdMsgs(p,rc[1],'make')
    319333    continue
    320334
     
    327341  # Check if 'make test' worked
    328342  if didTestFail(rc,p,"make test") :
    329     sendmail(p,rc[1],"make test")
     343    sendEmailCmdMsgs(p,rc[1],"make test")
    330344    continue
    331345
     
    345359 
    346360    if didTestFail(rc,p,unitTestCmd) :
    347       sendmail(p,rc[1],unitTestCmd)
     361      sendEmailCmdMsgs(p,rc[1],unitTestCmd)
    348362      continue
    349363
Note: See TracChangeset for help on using the changeset viewer.