示例#1
0
def find_monitor_obs(obsid):

    """
    for a given obsid, check all other obsid on the same monitor list. return monitor_list.

    """

    db_user = '******'
    server  = 'ocatsqlsrv'

    line      = pass_dir + '.targpass'
    f         = open(line, 'r')
    db_passwd = f.readline().strip()
    f.close()
    database  = 'axafocat'

    db = DBI(dbi='sybase', server=server, user=db_user, passwd=db_passwd, database=database)

    monitor_list = [obsid]
    series_rev(obsid, db, monitor_list)
    series_fwd(obsid, db, monitor_list)

    monitor_list = tdfnc.removeDuplicate(monitor_list, sorted="Yes")


    return monitor_list
示例#2
0
def read_ddt_too_from_email():

    """
    extreact TOO/DDT obsid from cus email achive. 
    input:  none, but read from the current email archive
    output: [tooList, ddtList]  --- a list of tooList and ddtList
    """
    #
    # --- read email archive
    #
    f = open("/arc/cus/mail_archive", "r")
    data = [line.strip() for line in f.readlines()]
    f.close()

    #
    # --- find certain signatures for TOO/DDT observation approved email, and extract their obsids
    #

    tooSet = []
    ddtSet = []
    for ent in data:

        m1 = re.search("Obsid", ent)

        if m1 is not None:
            m2 = re.search("Seq", ent)
            m5 = re.search("Prop", ent)

            if m2 is not None:

                m3 = re.search("is a TOO", ent)
                m4 = re.search("is a DDT", ent)

                if m3 is not None:
                    obsid = getObsid(ent)
                    tooSet.append(obsid)

                elif m4 is not None:
                    obsid = getObsid(ent)
                    ddtSet.append(obsid)

            elif m5 is not None:

                m6 = re.search("is a TOO", ent)
                m7 = re.search("is a DDT", ent)

                if m6 is not None:
                    obsid = getObsid(ent)
                    tooSet.append(obsid)

                elif m7 is not None:
                    obsid = getObsid(ent)
                    ddtSet.append(obsid)
    #
    # --- TOO case
    #
    tooList = []
    if len(tooSet) > 0:
        #
        # ---- remove duplicated entries
        #
        tempList = tdfnc.removeDuplicate(tooSet, sorted="yes")
        #
        # ---- only "unobserved" status ones are probably actually new.
        #
        if len(tempList) > 0:
            for ent in tempList:
                status = get_obs_status(ent)
                if status == "unobserved":
                    tooList.append(ent)
    #
    # --- DDT case
    #
    ddtList = []
    if len(ddtSet) > 0:
        tempList = tdfnc.removeDuplicate(ddtSet, sorted="yes")

        if len(tempList) > 0:
            for ent in tempList:
                status = get_obs_status(ent)
                if status == "unobserved":
                    ddtList.append(ent)

    return [tooList, ddtList]
示例#3
0
def read_ddt_too_from_email(tooList, ddtList):
    """
    extreact TOO/DDT obsid from cus email achive. no input, but need tooList, ddtList.
    """

    #
    #--- read email archive
    #
    f = open('/arc/cus/mail_archive', 'r')
    data = [line.strip() for line in f.readlines()]
    f.close()

    #
    #--- find certain signatures for TOO/DDT observation approved email, and extract their obsids
    #

    tooSet = []
    ddtSet = []
    tchk = 0
    dchk = 0
    for ent in data:

        m1 = re.search('Obsid', ent)

        if m1 is not None:
            m2 = re.search('Seq', ent)
            m5 = re.search('Prop', ent)

            if m2 is not None:

                #                m3 = re.search('is a TOO which has recently', ent)
                #                m4 = re.search('is a DDT which has recently', ent)
                m3 = re.search('is a TOO', ent)
                m4 = re.search('is a DDT', ent)

                if m3 is not None:
                    obsid = getObsid(ent)
                    tooSet.append(obsid)
                    tchk += 1

                elif m4 is not None:
                    obsid = getObsid(ent)
                    ddtSet.append(obsid)
                    dchk += 1

            elif m5 is not None:

                m6 = re.search('is a TOO', ent)
                m7 = re.search('is a DDT', ent)

                if m6 is not None:
                    obsid = getObsid(ent)
                    tooSet.append(obsid)
                    tchk += 1

                elif m7 is not None:
                    obsid = getObsid(ent)
                    ddtSet.append(obsid)
                    dchk += 1

#
#---- remove duplicated entries
#

    tlen = 0
    dlen = 0
    if tchk > 0:
        tempList = tdfnc.removeDuplicate(tooSet, sorted='yes')
        tlen = len(tempList)
        if tlen > 0:
            for ent in tempList:
                monitor = []
                group = []
                sqlinfo = tdsql.get_target_info(ent, monitor, group)
                status = sqlinfo[8]
                if status == 'unobserved':
                    tooList.append(ent)

    if dchk > 0:
        tempList = tdfnc.removeDuplicate(ddtSet, sorted='yes')
        dlen = len(tempList)
        if dlen > 0:
            for ent in tempList:
                monitor = []
                group = []
                sqlinfo = tdsql.get_target_info(ent, monitor, group)
                status = sqlinfo[8]
                if status == 'unobserved':
                    ddtList.append(ent)

    return tlen + dlen
示例#4
0
def read_ddt_too_from_email():

    """
    extreact TOO/DDT obsid from cus email achive. 
    input:  none, but read from the current email archive
    output: [tooList, ddtList]  --- a list of tooList and ddtList
    """
#
#--- read email archive
#
    f    = open('/arc/cus/mail_archive', 'r')
    data = [line.strip() for line in f.readlines()]
    f.close()

#
#--- find certain signatures for TOO/DDT observation approved email, and extract their obsids
#

    tooSet = []
    ddtSet = []
    for ent in data:

        m1 = re.search('Obsid', ent)

        if m1 is not None: 
            m2 = re.search('Seq',   ent)
            m5 = re.search('Prop',  ent)

            if m2 is not None: 

                m3 = re.search('is a TOO',   ent)
                m4 = re.search('is a DDT',   ent)

                if m3 is not None:
                    obsid = getObsid(ent)
                    tooSet.append(obsid)

                elif m4 is not None:
                    obsid = getObsid(ent)
                    ddtSet.append(obsid)

            elif m5 is not None: 

                m6 = re.search('is a TOO',   ent)
                m7 = re.search('is a DDT',   ent)

                if m6 is not None:
                    obsid = getObsid(ent)
                    tooSet.append(obsid)

                elif m7 is not None:
                    obsid = getObsid(ent)
                    ddtSet.append(obsid)
#
#--- TOO case
#
    tooList = []
    if len(tooSet) > 0:
#
#---- remove duplicated entries
#
        tempList = tdfnc.removeDuplicate(tooSet, sorted='yes')
#
#---- only "unobserved" status ones are probably actually new. 
#
        if len(tempList) > 0:
            for ent in tempList:
                status = get_obs_status(ent)
                if status == 'unobserved':
                    tooList.append(ent)
#
#--- DDT case
#
    ddtList = []
    if len(ddtSet) > 0:
        tempList = tdfnc.removeDuplicate(ddtSet, sorted='yes')

        if len(tempList)> 0:
            for ent in tempList:
                status = get_obs_status(ent)
                if status == 'unobserved':
                    ddtList.append(ent)

    return [tooList, ddtList]
示例#5
0
def read_ddt_too_from_email():

    """
    extreact TOO/DDT obsid from cus email achive. 
    input:  none, but read from the current email archive
    output: [tooList, ddtList]  --- a list of tooList and ddtList
    """
    #ifile = '/stage/mail/mta'
    ifile = '/data/mta4/CUS/www/Usint/TOO_Obs/Mscript/mta_mail'

    f     = open(ifile, 'r')
    data  = [line.strip() for line in f.readlines()]
    f.close()

    tooSet = []
    ddtSet = []

    chk    = 0
    for ent in data:
        if chk == 0:
            mc1 = re.search('Recently Approved ', ent)
            if mc1 is not None:
                mc = re.search('Subject', ent)
                if mc is not None:
                    mc = re.search('Re:', ent)
                    if mc is None:
                        chk = 1
            else:
                continue
        else:
            mc2 = re.search('From:',  ent)
            if mc2 is not None:
                chk = 0
                continue

            mc3 = re.search('Obsid ', ent)
            if mc3 is not None:
                atemp = re.split('\s+', ent)
                obsid = atemp[1].strip()

                mc = re.search('DDT', ent)
                if mc is not None:
                    ddtSet.append(int(obsid))
                else:
                    tooSet.append(int(obsid))

                chk = 0
#
#--- TOO case
#
    tooList = []
    if len(tooSet) > 0:
#
#---- remove duplicated entries
#
        tempList = tdfnc.removeDuplicate(tooSet, sorted='yes')
#
#---- only "unobserved" status ones are probably actually new. 
#
        if len(tempList) > 0:
            for ent in tempList:
                status = get_obs_status(ent)
                if status == 'unobserved':
                    tooList.append(ent)
#
#--- DDT case
#
    ddtList = []
    if len(ddtSet) > 0:
        tempList = tdfnc.removeDuplicate(ddtSet, sorted='yes')

        if len(tempList)> 0:
            for ent in tempList:
                status = get_obs_status(ent)
                if status == 'unobserved':
                    ddtList.append(ent)

    return [tooList, ddtList]