Beispiel #1
0
def send_out_exp_app_confirmation_email(alist, or_list, poc):
    """
    send out approved confirmation email
    input:  alist   --- a list of obsids
            or_list --- a list of obsids which are on OR list
            poc     --- POC
    output: email to POC
        """
#
#--- find poc email address
#
    email = oda.get_email_address(poc)
#
#--- check whether there are more than one entry
#
    if len(alist) == 1:
        content = "\n\nThe following obsid is added on the approved list, and ready for the flight.\n\n"
    else:
        content = "\n\nThe following obsids are added on the approved list, and ready for the flight.\n\n"
#
#--- create a list of obsid/obsidrev
#
    for obsid in alist:
        rev  = oda.find_the_last_rev(obsid)
        obsidrev = str(obsid) + '.' + str(rev)
        content = content + '\t\t' + str(obsid) + ': '
        content = content + durl + '/chkupdata/'  + str(obsidrev)  + '\n'
        if obsid in or_list:
            content = content + ' --- On OR list\n'
        else:
            content = content + '\n'

    subject = 'Approved Observation Notification'

    send_email(email, subject, content)
Beispiel #2
0
def send_email(address, subject, content, cc = '', submitter=''):
    """
    sending out email
    input:  address     --- email address. it can be multiple addresses, delimiated by ','.
            subject     --- head line of the email
            content     --- email content
            cc          --- cc email address; default: <blank> (no cc address)
    outout: email sent out
    """
#
#--- if this is a test, all email is sent to the submitter
#
    if test == 'yes':
        if submitter == '':
            address = admin
        else: 
            address = oda.get_email_address(submitter)


    fo = open(zspace, 'w')
    fo.write(content)
    fo.close()

    if cc == '':
        #cmd = 'cat ' + zspace + ' |mailx -s "Subject: ' + subject + '" ' + ' -b ' + admin + ' '  + address 
        cmd = 'cat ' + zspace + ' |mailx -s "Subject (TEST!!): ' + subject + '" ' + address  
    else:
        #cmd = 'cat ' + zspace + ' |mailx -s "Subject: ' + subject + '" ' + ' -c' + cc  + ' -b ' + admin + ' ' + address
        cmd = 'cat ' + zspace + ' |mailx -s "Subject (TEST!!): ' + subject + '" ' + ' -c' + cc + ' ' + address

    os.system(cmd)

    mcf.rm_file(zspace)
Beispiel #3
0
def send_verified_email(obsidrev, app_status, poc):
    """
    sending out this observation parameters are verified
    input:  obsidrev    --- obsid + revision #
            app_status  --- is this approved state? if so 1, else 0
            poc         --- person in charge
    output: email sent to poc
    """

    obsidrev = str(obsidrev)
    atemp    = re.split('\.', obsidrev)
    obsid    = atemp[0]

    address = oda.get_email_address(poc)

    subject = 'Subject: Signed Off Notice: ' + str(obsid)

    text1   = 'All requested edits have been made for the following obsid.rev: ' + str(obsidrev) + '. '
    text2   = 'This observation will be automatically approved in 24 hrs. '
    text3   = '\n\nPlease remember you still need to approve the observation at: ' 
    text3   = text3 + durl + '/ocatdatapage/' + str(obsid)
    text4   = '\n\nThis message is generated by a sign-off web page, so no reply is necessary.\n'

    if app_status == 1:
        content = text1 + text2 + text4
    else:
        content = text1 + text3 + text4

    send_email(address, subject, content)
Beispiel #4
0
def update_too_poc_file(poc):
    """
    write today's poc email address to TOO-POC file
    input:  poc         --- poc
    output  TOO-POC     --- a file contain email address of the poc
    """

    email = oda.get_email_address(poc)
    #
    #--- write it out
    #
    ###ofile = '/home/mta/TOO-POC'
    ofile = base_dir + 'ocatsite/data_save/' + 'TOO-POC'

    f = open(ofile, 'w')
    f.write(email)
    f.write('\n')
    f.close()

    cmd = 'chmod 644 ' + ofile
    os.system(cmd)
Beispiel #5
0
def send_lts_warning_email(lts_diff, submitter, obsid, rev):
    """
    send out lts late submission warning email
    input:  lts_diff    --- the numbers of days to lts date
            submitter   --- poc
            obsid       --- obsid
            rev         --- rev #
    output: warning email
    """
#
#--- poc email address
#
    email_address = oda.get_email_address(submitter)
#
#--- find out who is the mp contact person for this obsid
#
    mp_contact = ''
    mfile = obs_ss + 'scheduled_obs'
    f     = open(mfile, 'r')
    data  = [line.strip() for line in f.readlines()]
    f.close()

    for ent in data:
        atemp = re.split('\s+', ent)
        msave = atemp[1]
        if str(obsid) == atemp[0]:
            mp_contact = atemp[1]
            break
#
#--- if no mp is assigned for this obsid, use the last person listed on the list
#
    if mp_contact  == '':
        mp_contact = msave

    mp_email = mp_contact + '@head.cfa.harvard.edu'
#
#--- create email content
#
    content  =  "Its Ocat Data Page is:\n"
    content  = content + durl + "/ocatdatapage/" + str(obsid) + "\n\n\n"
    content  = content + "If you like to see what were changed:\n"
    content  = content + durl + "/chkupdata/" + str(obsid) + '.' + str(rev) + "\n\n\n"
    content  = content + "If you have any question about this email, please contact "
    content  = content + "[email protected].\n\n\n"
#
#--- email to mp contact
#
    content2 =  "\n\nA user: "******" submitted changes of  "
    content2 = content2 + "OBSID: " + str(obsid) + " which is scheduled in " + str(lts_diff) + " days.\n\n"
    content2 = content2 + "The contact email_address address is: " + email_address + "\n\n"
    content2 = content2 + content
#
#--- email to poc
#
    content3 =  "\n\nA You submitted changes of  "
    content3 = content3 + "OBSID: " + str(obsid) + " which is scheduled in " + str(lts_diff) + " days.\n\n"
    content3 = content3 + "The email_address of MP of this observation: " + mp_email + '\n\n'
    content3 = content3 + content
#
#--- send email out
#
    headline   = 'Change to Obsid $obsid Which Is Scheduled in ' + str(lts_diff) + ' days'
    send_email(mp_email,      headline, content2, submitter=submitter)

    if test == 'yes':
        headline   = 'Change to Obsid $obsid Which Is Scheduled in' +  str(lts_diff) + ' days (' + mp_email + ')'

    send_email(email_address, headline, content3, submitter=submitter)
Beispiel #6
0
def create_emails_and_save_log(dat_dict):
    """
    create a log for the upated values and send email
    input:  dat_dict    --- updated data dictionary
    output: email       --- email sent to the submitter
            log         --- a log in the form of obsid.revsion
    """
    obsid    = str(dat_dict['obsid'])
    rev      = oda.set_new_rev(obsid)
    obsidrev = str(obsid) + '.' + str(rev)
    user     = dat_dict['submitter']
    email    = oda.get_email_address(user)
#
#--- approved notification -----------------------------------
#   
    if dat_dict['asis'] == 'asis':
#
#--- add to approved list
#
        add_to_approved(dat_dict)
#
#--- add to updates data list/file
#
        oda.add_new_entry_to_update_list(dat_dict)
#
#--- sending out notification email
#
        content  = str(obsid) + ' is added on the approved list for flight. Thank you. \n\n'
        content  = content + oda.print_out_update_entries(obsidrev)
        headline = str(obsid) + ' Is Added On The Approved List For Flight.'
        send_email(email, headline, content)

#
#--- removed notification -----------------------------------
#   
    elif dat_dict['asis'] == 'remove':
#
#--- now delete it from approved list 
#
        oda.delete_from_approved_list(obsid)
#
#--- sending out notification email
#
        content  = str(obsid) + ' is removed from the approved list for flight. Thank you. \n'
        headline = str(obsid) + ' Is Removed From The Approved List For Flight.'
        send_email(email, headline, content)
#
#--- split notification -------------------------------------
#   
    elif dat_dict['asis'] == 'clone':
#
#--- add to updates data list/file
#
        ###oda.add_new_entry_to_update_list(dat_dict)
#
#--- sending out notification email
#
        content  = 'A split request for ' + obsid + ' is created. Thank you. \n'
        headline = 'Split Request For '   + obsid + ' Is Created.'
        send_email(email, headline, content)
#
#--- standard notification to the submitter ------------------
#
    elif dat_dict['asis'] == 'norm':
#
#--- add to updates data list/file
#
        oda.add_new_entry_to_update_list(dat_dict)
#
#--- sending out notification email
#
        content  = oda.print_out_update_entries(obsidrev)
        headline = 'Prameter Change Log: ' + obsidrev
        send_email(email, headline, content)
#
#--- OR notification ----------------------------------------
#
    try:
        check = dat_dict['or_notice']
        if check == 'yes':
            send_or_notification(obsid, rev, user, email)
    except:
        pass
Beispiel #7
0
    atemp    = re.split('\.', obsidrev)
    obsid    = atemp[0]
#
#--- if this is general/acis sign off, ask to sign off si mode, unless si mode is already signed off
#--- if that is the case, ask poc to verify
#
    if case in [1, 2]:
        if status[3] == 'NA':
            address = '*****@*****.**'
            subject = otype.upper() + ' SI Status Signed Off Request: OBSID: ' + str(obsid)
            if case == 1:
                content = si_text
            else:
                content = acis_text
        else:
            address = oda.get_email_address(poc)
            subject = otype.upper() + ' Verification Signed Off Request: OBSID: ' + str(obsid)
            content = verify_text
#
#--- if this is si mode sign off, ask poc to verify
#
    elif case == 3:
        address = oda.get_email_address(poc)
        subject = otype.upper() + ' Verification Signed Off Request: OBSID: ' + str(obsid)
        content = verify_text

    else:
        return None

    return [address, subject, content]