Example #1
0
def erroremail(obsdate, server='', username='', password='', sender='', recipient='', bcc='',
              sdbhost='sdb.salt', sdbname='sdb', sdbuser='', sdbpass='', logfile='saltlog.log', verbose=True):
    """Update the PipelineStatistics table with the current information
       about the pipeline

    """

    with logging(logfile,debug) as log:

       #connect the database
       sdb=saltmysql.connectdb(sdbhost, sdbname, sdbuser, sdbpass)

       #get the nightinfo_id
       night_id=saltmysql.getnightinfoid(sdb, obsdate)

       #create the message

       try:
          record=saltmysql.select(sdb, 'PipelineStatus, ErrorMessage', 'PipelineStatistics join PipelineStatus using (PipelineStatus_Id)', 'NightInfo_Id=%i' % night_id)
          status, error_message=record[0]
       except Exception, e:
          raise SaltError('Unable to download information: %s' % e)

       #set up the subject and message
       subject='Pipeline Error on %s' % obsdate
       
       message="Failure is simply the opportunity to begin again, this time more intelligently.--Henry Ford\n\n"  
       message+="%s" %  error_message
       log.message(message, with_stdout=verbose)

       #send the email
       saltio.email(server,username,password,sender,recipient,bcc, subject,message)
Example #2
0
def notifybvituser(sdb, pid, obsdate, server,username,password,sender, bcc, emailfile):
    """Send email notification to the user"""
    
    propinfo=findpropinfo(pid,sdb)

    for surname, recipient in zip(propinfo[pid][0], propinfo[pid][1]):
        subject='BVIT data available for download for %s' % pid
        msg=open(emailfile).read()
        msg=msg.replace('YYYY-INST-PID',pid.upper())
        msg=msg.replace('yyyymmdd',obsdate)
        saltio.email(server,username,password,sender,recipient,bcc, subject,msg)
Example #3
0
                   sdbname=sdbname,sdbuser=sdbuser,splitfiles=True, 
                   cleanup=True,clobber=True,logfile=logfile, verbose=verbose)
           except Exception,e:
               message="Not able to copy data to FTP area:\n%s " % e
               raise SaltError(message)     
           #try moving the BVIT data
           try:
               bvitfile= iraf.osfn('pipetools$html/readme.bvit.template')
               bvitftp('ALL', obsdate, sdbhost=sdbhost,sdbname=sdbname,sdbuser=sdbuser, 
                       password=ftppasswd, server=emserver,username=emuser,sender=sender, 
                       bcc=bcc, emailfile=bvitfile, notify=True, clobber=True,
                       logfile=logfile, verbose=verbose)
           except Exception, e:
               message="ERROR: Not able to copy BVIT to FTP area:\n%s " % e
               print SaltError(message)     
               saltio.email(emserver,emuser,ftppassword,sender,'*****@*****.**','', 'BVIT Died',message)
           



       #send notifications if emails have not already been sent
       #first check to see if emails have been sent
       sdb=saltmysql.connectdb(sdbhost, sdbname, sdbuser, sdbpass)
       if email:
          record=saltmysql.select(sdb, 'EmailSent', 'PipelineStatistics', 'NightInfo_Id=%i' % nightinfoid)
          if len(record)>0:
             if record[0][0]==1:  
               email=False
               log.warning("According to the Sdb, notifications have already been sent for %s." % obsdate)

       if int(obsdate)<20110901: