示例#1
0
def getbvitproposalcodes(obsdate):
    """Retrieve all the proposal observed on a given date"""
    pids=glob.glob('/salt/bvit/data/%s/%s/*-*-*' % (obsdate[0:4], obsdate[4:8]))
    for p in pids:
        if p.count('Detector-Background'):pids.remove(p)
    pids=saltio.removebadpids(pids)
    pids=saltio.removeengineeringpids(pids)
    return pids
示例#2
0
def getpropcodes(sdb, obsdate, clean=True):
    """Return all proposal codes for an observing date"""
    state_select='Distinct Proposal_Code'
    state_from='FileData join ProposalCode using (ProposalCode_Id)'
    state_logic="FileName like '%"+obsdate+"%'"
    record=select(sdb,state_select,state_from,state_logic)
    if len(record)==0:
       return []
    else:
       pids=[x[0] for x in record]
    if clean:
       pids=saltio.removebadpids(pids)
       pids=saltio.removeengineeringpids(pids)
    return pids
示例#3
0
def getpropcodes(sdb, obsdate, clean=True):
    """Return all proposal codes for an observing date"""
    state_select = 'Distinct Proposal_Code'
    state_from = 'FileData join ProposalCode using (ProposalCode_Id)'
    state_logic = "FileName like '%" + obsdate + "%'"
    record = select(sdb, state_select, state_from, state_logic)
    if len(record) == 0:
        return []
    else:
        pids = [x[0] for x in record]
    if clean:
        pids = saltio.removebadpids(pids)
        pids = saltio.removeengineeringpids(pids)
    return pids
示例#4
0
       records=saltmysql.select(sdb, select, table, logic)

       if len(records)<1:  
          msg="No observations available for %s" % obsdate
          log.warning(msg)
          return
       else:
          for p in records:
              propids.append(p[0])

       #clean the proposal list
       print pids, propids
       try:
           pids=saltio.cleanpropcode(pids, propids)
           pids=saltio.removebadpids(pids)
           pids=saltio.removeengineeringpids(pids)
       except SaltIOError:
           msg="No notifications necessary for %s" % obsdate
           log.warning
           return

       #loop through each of the pids and send the email
       for pid in pids:
         propinfo=findpropinfo(pid, sdb)
         if propinfo:
           for pi, email in zip(propinfo[pid][0], propinfo[pid][1]):
               letter=saltio.openascii(readme,'r')
               msg=letter.read()
               msg=msg.replace('yourname',pi)
               msg=msg.replace('YYYY-INST-PID',pid.upper())
               msg=msg.replace('yyyymmdd',obsdate)