Changeset 617 for branches


Ignore:
Timestamp:
Oct 15, 2007 11:45:18 AM (12 years ago)
Author:
jpfasano
Message:

Moved email functions to their own file

Location:
branches/testScripts
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/testScripts/NBuserConfig.py

    r614 r617  
    5555#----------------------------------------------------------------------
    5656PROJECTS = ['CoinUtils','DyLP','Clp','SYMPHONY','Vol','Osi','Cgl','Cbc','Ipopt','OS','CppAD']
    57 PROJECTS = ['Clp','CppAD']
     57PROJECTS = ['CoinUtils','CppAD']
    5858
    5959
  • branches/testScripts/nightlyBuild.py

    r615 r617  
    1010import NBprojectConfig
    1111import NBlogMessages
     12import NBemail
    1213
    1314# TODO:
     
    2425#     to test on in an email dated 10/12/2007 12:01pm
    2526
    26 
    27 #------------------------------------------------------------------------
    28 # Send email typically about an error.
    29 #  project: coin project name
    30 #  cmd: command being exucuted. perhaps: "svn update", "./configure",
    31 #       "make".
    32 #  cmdMsgs: the messages generated by cmd.  This will typically contain
    33 #       errors issued by cmd.
    34 #------------------------------------------------------------------------
    35 def sendEmailCmdMsgs(project,cmdMsgs,cmd):
    36   curDir = os.getcwd()
    37  
    38   toAddrs = [unscrambleEmailAddress(NBuserConfig.MY_EMAIL_ADDR)]
    39   if NBprojectConfig.PROJECT_EMAIL_ADDRS.has_key(project) and NBuserConfig.SEND_MAIL_TO_PROJECT_MANAGER:
    40     toAddrs.append(unscrambleEmailAddress(NBprojectConfig.PROJECT_EMAIL_ADDRS[project]))
    41 
    42   subject = project + " build problem when running '" + cmd +"'"
    43 
    44   emailMsg  = "'" + cmd + "' from directory " + curDir + " failed.\n\n"
    45   emailMsg += "Operating System: "+os.name
    46   emailMsg += "'" + cmd + "' messages are:\n"
    47   emailMsg += cmdMsgs
    48   sendEmail(toAddrs,subject,emailMsg)
    49   NBlogMessages.writeMessage( "  email sent regarding "+project+" running '"+cmd+"'" )
    50 
    51 #------------------------------------------------------------------------
    52 # Send email
    53 #------------------------------------------------------------------------
    54 def sendEmail(toAddrs,subject,message):
    55 
    56   sender = unscrambleEmailAddress(NBuserConfig.SENDER_EMAIL_ADDR) 
    57   msgWHeader = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n"
    58        % (sender, ", ".join(toAddrs), subject))
    59   msgWHeader += message
    60  
    61   # Get smpt server password
    62   if os.path.isfile(NBuserConfig.SMTP_PASSWORD_FILENAME) :
    63     pwFilePtr = open(NBuserConfig.SMTP_PASSWORD_FILENAME,'r')
    64     smtppass  = pwFilePtr.read().strip()
    65     pwFilePtr.close()
    66   else :
    67     NBlogMessages.writeMessage( "Failure reading pwFileName=" + NBuserConfig.SMTP_PASSWORD_FILENAME )
    68     sys.exit(1)
    69    
    70   session = smtplib.SMTP(NBuserConfig.SMTP_SERVER_NAME,NBuserConfig.SMTP_SERVER_PORT)
    71   #session.set_debuglevel(1)
    72   if NBuserConfig.SMTP_SSL_SERVER==1 :
    73     session.ehlo('x')
    74     session.starttls()
    75     session.ehlo('x') 
    76   session.login(unscrambleEmailAddress(NBuserConfig.SMTP_USER_NAME),smtppass)
    77 
    78   rc = session.sendmail(sender,toAddrs,msgWHeader)
    79   if rc!={} :
    80     NBlogMessages.writeMessage( 'session.sendmail rc='  )
    81     NBlogMessages.writeMessage( rc )
    82   session.quit()
    83 
    84 #------------------------------------------------------------------------
    85 # Decrypt email address
    86 #------------------------------------------------------------------------
    87 def unscrambleEmailAddress( scrambledEmailAddress ) :
    88   retVal = scrambledEmailAddress
    89   retVal = retVal.replace(' _AT_ ','@')
    90   retVal = retVal.replace(' _DOT_ ','.')
    91   return retVal
    9227
    9328#------------------------------------------------------------------------
     
    14378  rc=commands.getstatusoutput(svnCmd)
    14479  if rc[0] != 0 :
    145     sendEmailCmdMsgs(project,rc[1],svnCmd)
     80    NBemail.sendCmdMsgs(project,rc[1],svnCmd)
    14681    retVal='Error'
    14782  return retVal
     
    223158      error_msg += logFilePtr.read()
    224159      logFilePtr.close()
    225     sendEmailCmdMsgs(p,error_msg,configCmd)
     160    NBemail.sendCmdMsgs(p,error_msg,configCmd)
    226161    continue
    227162
     
    234169  # Check if make worked
    235170  if rc[0] != 0 :
    236     sendEmailCmdMsgs(p,rc[1],'make')
     171    NBemail.sendCmdMsgs(p,rc[1],'make')
    237172    continue
    238173
     
    245180  # Check if 'make test' worked
    246181  if didTestFail(rc,p,"make test") :
    247     sendEmailCmdMsgs(p,rc[1],"make test")
     182    NBemail.sendCmdMsgs(p,rc[1],"make test")
    248183    continue
    249184
     
    263198 
    264199    if didTestFail(rc,p,unitTestCmd) :
    265       sendEmailCmdMsgs(p,rc[1],unitTestCmd)
     200      NBemail.sendCmdMsgs(p,rc[1],unitTestCmd)
    266201      continue
    267202
Note: See TracChangeset for help on using the changeset viewer.