コード例 #1
0
def bpm_msg(data, axis):
    # BPMs are numbered 1 through 4
    # index 0 contains refrence data,
    # and the last index contains the most recent sampling
    db_cmd = db_commands()
    # divide by 100 because the database stores % not floats between 0 and 1
    deviation = db_cmd.get_setting('deviation') / 100.
    del db_cmd
    check_centre = False
    check_fwhm = False
    msg = ""
    for d in data:
        j = 'fwhm'
        if ((d[-1][j] > (1 + deviation) * d[0][j])
                or (d[-1][j] < (1 - deviation) * d[0][j])):
            msg += 'Large deviation in the ' + j + ' of ' + str(
                d[-1]['title']) + '\n'
            msg += ' reference ' + j + ' ' + str(d[0][j]) + '\n'
            msg += ' current ' + j + ' ' + str(d[-1][j]) + '\n'
            if (j == 'fwhm'):
                check_fwhm = True
        if abs(d[-1]['centre']) >= 4.5:
            msg += 'Off centre: ' + str(d[-1]['centre']) + " of " + str(
                d[-1]['title']) + '\n'
            check_centre = True  #reference with the mwpc
    return msg, check_centre, check_fwhm
コード例 #2
0
 def update_spinbox_vals(self):
     db_cmd = db_commands()
     self.downTimeBox.setValue(db_cmd.get_setting('downtime'))
     self.deviationBox.setValue(db_cmd.get_setting('deviation'))
     self.secRefBox.setValue(db_cmd.get_setting('sec_ref'))
     self.mwpcVFwhmRefBox.setValue(db_cmd.get_setting('mwpc_V_FWHM'))
     self.mwpcHFwhmRefBox.setValue(db_cmd.get_setting('mwpc_H_FWHM'))
     self.mwpcVCentreRefBox.setValue(db_cmd.get_setting('mwpc_V_center'))
     self.mwpcHCentreRefBox.setValue(db_cmd.get_setting('mwpc_H_centre'))
コード例 #3
0
ファイル: cst_gui.py プロジェクト: einoj/charm_shift_tool
 def update_spinbox_vals(self):
   db_cmd = db_commands()
   self.downTimeBox.setValue(db_cmd.get_setting('downtime'))
   self.deviationBox.setValue(db_cmd.get_setting('deviation'))
   self.secRefBox.setValue(db_cmd.get_setting('sec_ref'))
   self.mwpcVFwhmRefBox.setValue(db_cmd.get_setting('mwpc_V_FWHM'))
   self.mwpcHFwhmRefBox.setValue(db_cmd.get_setting('mwpc_H_FWHM'))
   self.mwpcVCentreRefBox.setValue(db_cmd.get_setting('mwpc_V_center'))
   self.mwpcHCentreRefBox.setValue(db_cmd.get_setting('mwpc_H_centre'))
コード例 #4
0
 def alert_checked(self, state):
   sender = self.sender()
   try:
     idx = int(sender.objectName().split('_')[-1])
   except ValuError:
     print('Error! not a string')
     idx = 0
     return
   name = self.usernames[idx].text()
   #email = self.emailEdits[idx].text()
   #phone = self.phoneEdits[idx].text()
   alert = state*1 # convert True, False to 1, 0
   db_cmd = db_commands()
   db_cmd.set_alert((name,alert))
コード例 #5
0
def check_SEC():
    db_cmd = db_commands()
    dv = db_cmd.get_setting('deviation')
    if dv == None:
        #if there is no deviation setting use 30 as default
        dv = 30
    deviation = dv / 100.
    del db_cmd
    s = SEC()
    data = s.get_data()
    # intensity is the average over 15 minutes
    # tested at 20/08/2015  20:57:03 1.65e04
    # tested at 24/08/2015  20:57:02 1.62e04
    # tested at 20/08/2015  12:12:49 1.66e04
    # average is 1.64e04
    reference = 1.64e04 * calibration['SEC1']
    now = datetime.now()
    msg = ''
    warning = '{} - PROBLEM! NO BEAM!'.format(datetime.now())

    if type(data) == bool:
        # No recent sec data in timber
        return warning

    try:
        #check number of samples in last five minutes
        #there should be about 3.4 per minute
        #if it drops below 2.4 per minute, send a warning.
        #Do this because even if there has been no samples
        #in the last five miutes, the intensity will still be high enough.
        fiveminago = now - timedelta(minutes=5)
        samplecnt = 0
        timeindex = len(data.index) - 1
        while (data.index[timeindex] > fiveminago):
            samplecnt += 1
            timeindex -= 1
        if (samplecnt < 10):
            return warning

        # Enough samples in the last 5 minutes, return intensity
        intensity = (data['pot/spill'].mean())
        last_spill = data.index[-1]
        print("SEC intensity: " + str(intensity))
    except:
        return warning
    if ((intensity > (1 + deviation) * reference)
            or (intensity < (1 - deviation) * reference)):
        msg = 'SEC1 intesity: ' + str(intensity) + ' reference: ' + str(
            reference)
    return msg
コード例 #6
0
def check_SEC():
  db_cmd = db_commands()
  dv = db_cmd.get_setting('deviation')
  if dv == None:
    #if there is no deviation setting use 30 as default
    dv = 30
  deviation = dv/100.
  del db_cmd
  s = SEC()
  data = s.get_data()
  # intensity is the average over 15 minutes
  # tested at 20/08/2015  20:57:03 1.65e04
  # tested at 24/08/2015  20:57:02 1.62e04
  # tested at 20/08/2015  12:12:49 1.66e04
  # average is 1.64e04
  reference = 1.64e04*calibration['SEC1']
  now = datetime.now()
  msg = ''
  warning = '{} - PROBLEM! NO BEAM!'.format(datetime.now())

  if type(data) == bool:
    # No recent sec data in timber
    return warning

  try:
    #check number of samples in last five minutes
    #there should be about 3.4 per minute
    #if it drops below 2.4 per minute, send a warning.
    #Do this because even if there has been no samples 
    #in the last five miutes, the intensity will still be high enough.
    fiveminago  = now - timedelta(minutes=5)
    samplecnt = 0
    timeindex = len(data.index)-1
    while (data.index[timeindex] > fiveminago):
      samplecnt += 1
      timeindex -= 1
    if (samplecnt < 10):
      return warning

    # Enough samples in the last 5 minutes, return intensity
    intensity = (data['pot/spill'].mean())
    last_spill = data.index[-1]
    print ("SEC intensity: " + str(intensity))
  except:
    return warning
  if ((intensity > (1+deviation)*reference) or (intensity < (1-deviation)*reference)):
    msg =  'SEC1 intesity: ' + str(intensity) + ' reference: ' + str(reference)
  return msg
コード例 #7
0
 def user_email_changed(self):
   sender = self.sender()
   # Since the QLineEdits and user labels are labled 0,1,2...n
   # We can use the senders name to find the user name stored in the user label
   # This is very hacky, but I have spent too long trying to find
   # the correct way to do it...
   # Using split(_) because the name and number is devided by _ as in user_label_10
   try:
     idx = int(sender.objectName().split('_')[-1])
   except ValuError:
     print('Error! not a string')
     idx = 0
     return
   name = self.usernames[idx].text()
   email = sender.text()
   db_cmd = db_commands()
   db_cmd.set_shifter_email((name,email))
コード例 #8
0
def check_MWPC():
  db_cmd = db_commands()
  ref_fv = db_cmd.get_setting('mwpc_V_FWHM')
  ref_fh = db_cmd.get_setting('mwpc_H_FWHM')
  ref_cv = db_cmd.get_setting('mwpc_V_center')
  ref_ch = db_cmd.get_setting('mwpc_H_centre')
  deviation = db_cmd.get_setting('deviation')/100.
  del db_cmd
  m = MWPC()
  fwhm_msg = ""
  centre_msg = ""
  fwhm_v, fwhm_h, centre_v, centre_h = m.get_data()
  print ("MWPC: fwhm v: " + str(fwhm_v) + " fwhm_h: " + str(fwhm_h) + " centre_v: " + str(centre_v) + " centre_h: " + str(centre_h))
  if abs(centre_v) > (1+deviation)*ref_cv:
    centre_msg += "MWPC vertical center offset: " + str(centre_v) + " mm\n"
  if abs(centre_h) > (1+deviation)*ref_ch:
    centre_msg += "MWPC horizontal center offset: " + str(centre_h) + " mm\n"
  if fwhm_v > (1+deviation)*ref_fv:
    fwhm_msg += "MWPC vertical FWHM too large: " + str(fwhm_v) + " mm\n"
  if fwhm_h > (1+deviation)*ref_fh:
    fwhm_msg += "MWPC horizontal FWHM too large: " + str(fwhm_h) + " mm\n"
  return centre_msg, fwhm_msg
コード例 #9
0
def bpm_msg(data, axis):
  # BPMs are numbered 1 through 4
  # index 0 contains refrence data,
  # and the last index contains the most recent sampling
  db_cmd = db_commands()
  # divide by 100 because the database stores % not floats between 0 and 1
  deviation = db_cmd.get_setting('deviation')/100.
  del db_cmd
  check_centre = False
  check_fwhm = False
  msg = ""
  for d in data:
    j = 'fwhm'
    if ((d[-1][j] > (1+deviation)*d[0][j]) or (d[-1][j] < (1-deviation)*d[0][j])):
      msg += 'Large deviation in the ' + j + ' of ' + str(d[-1]['title']) + '\n'
      msg += ' reference ' + j + ' ' + str(d[0][j]) + '\n'
      msg += ' current ' + j + ' ' + str(d[-1][j]) + '\n'
      if (j == 'fwhm'):
        check_fwhm = True
    if  abs(d[-1]['centre'])  >= 4.5:
        msg += 'Off centre: ' + str(d[-1]['centre']) + " of " + str(d[-1]['title']) + '\n'
        check_centre = True #reference with the mwpc
  return msg, check_centre, check_fwhm
コード例 #10
0
def check_MWPC():
    db_cmd = db_commands()
    ref_fv = db_cmd.get_setting('mwpc_V_FWHM')
    ref_fh = db_cmd.get_setting('mwpc_H_FWHM')
    ref_cv = db_cmd.get_setting('mwpc_V_center')
    ref_ch = db_cmd.get_setting('mwpc_H_centre')
    deviation = db_cmd.get_setting('deviation') / 100.
    del db_cmd
    m = MWPC()
    fwhm_msg = ""
    centre_msg = ""
    fwhm_v, fwhm_h, centre_v, centre_h = m.get_data()
    print("MWPC: fwhm v: " + str(fwhm_v) + " fwhm_h: " + str(fwhm_h) +
          " centre_v: " + str(centre_v) + " centre_h: " + str(centre_h))
    if abs(centre_v) > (1 + deviation) * ref_cv:
        centre_msg += "MWPC vertical center offset: " + str(centre_v) + " mm\n"
    if abs(centre_h) > (1 + deviation) * ref_ch:
        centre_msg += "MWPC horizontal center offset: " + str(
            centre_h) + " mm\n"
    if fwhm_v > (1 + deviation) * ref_fv:
        fwhm_msg += "MWPC vertical FWHM too large: " + str(fwhm_v) + " mm\n"
    if fwhm_h > (1 + deviation) * ref_fh:
        fwhm_msg += "MWPC horizontal FWHM too large: " + str(fwhm_h) + " mm\n"
    return centre_msg, fwhm_msg
コード例 #11
0
ファイル: submit.py プロジェクト: ricastell/charm_shift_tool
import cgi
import cgitb
from database_ctrl import db_commands

cgitb.enable()
form = cgi.FieldStorage()

db_cmd = db_commands()
print("Content-type:text/html\r\n\r\n")
print('<html>')
print('<head>')
print('<title>CHARM Shift Tool</title>')
print('<link rel=stylesheet href="adminstyle.css" type="text/css" media=all>')
print('</head>')
print('<body>')
print('Sending Response... Please Wait')
shifters = db_cmd.get_all_shifters()
# Html forms do not send checkboxes if they are not checked
# therefore we must collect all users who had the alert box checked
# set their alert variable to 1 in the database and the rest to 0
alertees = []
for key in form.keys():
    if 'alert' in key:
        alertees.append(key.replace('alert', ''))
    if 'phone' in key:
        db_cmd.set_shifter_phone((key.replace('phone', ''), form[key].value))
    elif 'email' in key:
        db_cmd.set_shifter_email((key.replace('email', ''), form[key].value))
    else:
        db_cmd.insert_setting((key, form[key].value))
コード例 #12
0
def running():

  # If the shifter changes we want to send an email to the new shifter.
  prev_shifter = ''
  while True:
    xmsg = ""
    ymsg = ""
    centre_msg = ""
    fwhm_msg = ""
    sec_msg = ""
    beam_status = 1
    centre_status = 1
    fwhm_status = 1
    subject = "Warning "
    warn_email = False
    warn_centre_email = False
    warn_fwhm_email = False

    dbc = db_commands()

    last_msg = dbc.get_last_msg()
    response = dbc.get_response()

    # In order for the user and administrator intefaces to see all the shifters, they need to be stored in the database
    # To make sure that all shifters are stored in the data base we call get_all_shifters on both the database and the google sheet
    # Then we add all the shifters to the database that are in the google sheet but not yet in the database
    database_shifters = dbc.get_all_shifters()
    sheet_shifters = get_all_shifters()
    for name in sheet_shifters:
      if name not in database_shifters:
        dbc.insert_shifter({'name':name, 'email':'', 'phone':0, 'current':0, 'alert':0})


    shifter = get_shifter()
    alertees = dbc.get_alerts()
    recipients = []
    if shifter not in alertees:
      shifter_info = dbc.get_shifter_info(shifter)
      recipients.append(shifter_info['email'])
      sms = phone2email(shifter_info['phone'])
      recipients.append(sms)
    for name in alertees:
      shifter_info = dbc.get_shifter_info(name)
      recipients.append(shifter_info['email'])
      sms = phone2email(shifter_info['phone'])
      recipients.append(sms)

    # Send email if there is a new shifter
    if prev_shifter != shifter:
      prev_shifter = shifter
      dbc.set_current_shifter(shifter)
      shifttime=1400
      date,tomorrow = get_date(shifttime)
      shifter_msg = new_shifter_msg.format(shifter=shifter, date=date, tomorrow=tomorrow, shifttime=shifttime)
      print(shifter_msg)
      alert('New CHARM shifter {:s}'.format(shifter), shifter_msg, '*****@*****.**', recipients)
    
    #check only SEC for intensity
    sec_msg = check_SEC()
    if sec_msg != '':
      warn_email = True
      beam_status = 0
      centre_status = 0
      fwhm_status = 0
      subject += 'BEAM DOWN! '
    
    xmsg, ymsg, xcentre, xfwhm, ycentre, yfwhm, bpm_error = check_BPM()

    # Make sure the centre/fwhm is acutally off by also comparing to the SEC
    if (xfwhm or xcentre or ycentre or yfwhm or bpm_error):
      centre_msg, fwhm_msg = check_MWPC()
      if centre_msg != '':
        warn_centre_email = True
        subject += 'Beam off centre! '
      if fwhm_msg != '':
        warn_fwhm_email = True
        subject += 'Beam fwhm too wide '

    t_now = (datetime.now()).strftime(tf)

    # Only send message if we haven't already
    alert_msg = whole_msg.format(sec=sec_msg, x=xmsg, y=ymsg, centre=centre_msg, fwhm=fwhm_msg)    
    if last_msg is None:
        if warn_email or warn_fwhm_email or warn_centre_email:
            alert(subject, alert_msg, '*****@*****.**', recipients)
            dbc.insert_msg((t_now, alert_msg, 1*warn_email, 1*warn_fwhm_email, 1*warn_centre_email))
            dbc.respond(0)
    
    # Send the alerts if there is something wrong or if th ebeam is up again.
    else:
      if last_msg[-3] == 1 and warn_email:
        print(1)
        # If there is a warn_email, everything is down
        alert(subject, alert_msg, '*****@*****.**', recipients)
        dbc.insert_msg((t_now, alert_msg, 0, 0, 0))
        dbc.respond(0)
      elif last_msg[-3] == 0 and warn_email == False:
        print(2)
        # Beam is now up again
        alert("Notice CHARM beam is up again", "Beam up again at " + t_now, '*****@*****.**', recipients)
        dbc.insert_msg((t_now, "Beam up again.", 1,1*warn_fwhm_email,1*warn_centre_email))
        dbc.respond(1)
      elif (warn_fwhm_email == False and last_msg[-2] == 0) and (warn_centre_email == False and last_msg[-1] == 0):
        print(3)
        alert('Notic Beam Centered and FWHM Normal', alert_msg, '*****@*****.**', recipients)
        dbc.insert_msg((t_now, alert_msg, 1, 1, 1))
        dbc.respond(1)
      elif last_msg[-2] == 1 or last_msg[-1] == 1:
        print(4)
        # FWHM too large or Centre off
        if (warn_fwhm_email and last_msg[-2] == 1) or (warn_centre_email and last_msg[-1] == 1):
          alert(subject, alert_msg, '*****@*****.**', recipients)
          dbc.insert_msg((t_now, alert_msg, 1, 1*(not warn_fwhm_email), 1*(not warn_centre_email)))
          dbc.respond(0)
          # FWHM and Centre back to normal
        elif ((last_msg[-3] == 0 or last_msg[-2] == 0 or last_msg[-1] == 0) and response == (0,)):
          print(5)
          #Keep sending messages until user responds
          alert('Resending ' + subject, alert_msg, '*****@*****.**', recipients)
      elif ((last_msg[-3] == 0 or last_msg[-2] == 0 or last_msg[-1] == 0) and response == (0,)):
        print(5)
        #Keep sending messages until user responds
        alert('Resending ' + subject, alert_msg, '*****@*****.**', recipients)

    del dbc
    print(alert_msg)
    time.sleep(600)
コード例 #13
0
ファイル: submit.py プロジェクト: einoj/charm_shift_tool
import cgi
import cgitb
from database_ctrl import db_commands

cgitb.enable()
form = cgi.FieldStorage()

db_cmd = db_commands()
print("Content-type:text/html\r\n\r\n")
print('<html>')
print('<head>')
print('<title>CHARM Shift Tool</title>')
print('<link rel=stylesheet href="adminstyle.css" type="text/css" media=all>')
print('</head>')
print('<body>')
print('Sending Response... Please Wait')
shifters = db_cmd.get_all_shifters()
# Html forms do not send checkboxes if they are not checked
# therefore we must collect all users who had the alert box checked
# set their alert variable to 1 in the database and the rest to 0
alertees = []
for key in form.keys():
  if 'alert' in key:
    alertees.append(key.replace('alert',''))
  if 'phone' in key:
    db_cmd.set_shifter_phone((key.replace('phone',''),form[key].value))
  elif 'email' in key:  
    db_cmd.set_shifter_email((key.replace('email',''),form[key].value))
  else:
    db_cmd.insert_setting((key,form[key].value))
コード例 #14
0
 def update_msg(self):
     db_cmd = db_commands()
     msg = db_cmd.get_last_msg()
     msg = msg[2]
     _translate = QCoreApplication.translate
     self.plainTextEdit.setPlainText(_translate("MainWindow", msg))
コード例 #15
0
 def __init__(self):
   self.db_cmd = db_commands()
コード例 #16
0
ファイル: cst_gui.py プロジェクト: einoj/charm_shift_tool
 def update_msg(self):
   db_cmd = db_commands()
   msg = db_cmd.get_last_msg()
   msg = msg[2]
   _translate = QCoreApplication.translate
   self.plainTextEdit.setPlainText(_translate("MainWindow", msg))
コード例 #17
0
def running():

    # If the shifter changes we want to send an email to the new shifter.
    while True:
        xmsg = ""
        ymsg = ""
        centre_msg = ""
        fwhm_msg = ""
        sec_msg = ""
        beam_status = 1
        centre_status = 1
        fwhm_status = 1
        subject = "Warning "
        warn_email = False
        warn_centre_email = False
        warn_fwhm_email = False

        dbc = db_commands()

        last_msg = dbc.get_last_msg()
        response = dbc.get_response()
        downtime = dbc.get_setting('downtime')
        prev_shifter = dbc.get_current_shifter()

        try:
            downtime = int(downtime)
        except ValueError:
            #downtime was not a string; wait time 10 minutes by default
            downtime = 10
            print(
                'ERROR: downtime in database was not a string, sleeping for defualt 10 min'
            )
        downtime *= 60  #multiply by 60 to get seconds

        # In order for the user and administrator intefaces to see all the shifters, they need to be stored in the database
        # To make sure that all shifters are stored in the data base we call get_all_shifters on both the database and the google sheet
        # Then we add all the shifters to the database that are in the google sheet but not yet in the database
        database_shifters = dbc.get_all_shifters()
        sheet_shifters = get_all_shifters()
        for name in sheet_shifters:
            if name not in database_shifters:
                dbc.insert_shifter({
                    'name': name,
                    'email': '',
                    'phone': 0,
                    'current': 0,
                    'alert': 0
                })

        shifter = get_shifter()
        alertees = dbc.get_alerts()
        recipients = []
        if shifter not in alertees:
            shifter_info = dbc.get_shifter_info(shifter)
            recipients.append(shifter_info['email'])
            sms = phone2email(shifter_info['phone'])
            recipients.append(sms)
        for name in alertees:
            shifter_info = dbc.get_shifter_info(name)
            recipients.append(shifter_info['email'])
            sms = phone2email(shifter_info['phone'])
            recipients.append(sms)

        # Send email if there is a new shifter
        if prev_shifter != shifter:
            if shifter == '':
                #Something went wrong when getting shifter from google sheet, use prev shifter
                shifter = prev_shifter
            else:
                prev_shifter = shifter
                dbc.set_current_shifter(shifter)
                shifttime = 1400
                date, tomorrow = get_date(shifttime)
                shifter_msg = new_shifter_msg.format(shifter=shifter,
                                                     date=date,
                                                     tomorrow=tomorrow,
                                                     shifttime=shifttime)
                print(shifter_msg)
                alert('New CHARM shifter {:s}'.format(shifter), shifter_msg,
                      '*****@*****.**', recipients)

        #check only SEC for intensity
        sec_msg = check_SEC()
        if sec_msg != '':
            warn_email = True
            beam_status = 0
            centre_status = 0
            fwhm_status = 0
            subject += 'BEAM DOWN! '

        xmsg, ymsg, xcentre, xfwhm, ycentre, yfwhm, bpm_error = check_BPM()

        # Make sure the centre/fwhm is acutally off by also comparing to the SEC
        if (xfwhm or xcentre or ycentre or yfwhm or bpm_error):
            centre_msg, fwhm_msg = check_MWPC()
            if centre_msg != '':
                warn_centre_email = True
                subject += 'Beam off centre! '
            if fwhm_msg != '':
                warn_fwhm_email = True
                subject += 'Beam fwhm too wide '

        t_now = (datetime.now()).strftime(tf)

        # Only send message if we haven't already
        alert_msg = whole_msg.format(sec=sec_msg,
                                     x=xmsg,
                                     y=ymsg,
                                     centre=centre_msg,
                                     fwhm=fwhm_msg)
        if last_msg is None:
            if warn_email or warn_fwhm_email or warn_centre_email:
                alert(subject, alert_msg, '*****@*****.**',
                      recipients)
                dbc.insert_msg((t_now, alert_msg, 1 * warn_email,
                                1 * warn_fwhm_email, 1 * warn_centre_email))
                dbc.respond(0)

        # Send the alerts if there is something wrong or if th ebeam is up again.
        else:
            if last_msg[-3] == 1 and warn_email:
                print(1)
                # If there is a warn_email, everything is down
                alert(subject, alert_msg, '*****@*****.**',
                      recipients)
                dbc.insert_msg((t_now, alert_msg, 0, 0, 0))
                dbc.respond(0)
            elif last_msg[-3] == 0 and warn_email == False:
                print(2)
                # Beam is now up again
                alert("Notice CHARM beam is up again",
                      "Beam up again at " + t_now, '*****@*****.**',
                      recipients)
                dbc.insert_msg((t_now, "Beam up again.", 1,
                                1 * warn_fwhm_email, 1 * warn_centre_email))
                dbc.respond(1)
            elif (warn_fwhm_email == False and last_msg[-2]
                  == 0) and (warn_centre_email == False and last_msg[-1] == 0):
                print(3)
                alert('Notic Beam Centered and FWHM Normal', alert_msg,
                      '*****@*****.**', recipients)
                dbc.insert_msg((t_now, alert_msg, 1, 1, 1))
                dbc.respond(1)
            elif last_msg[-2] == 1 or last_msg[-1] == 1:
                print(4)
                # FWHM too large or Centre off
                if (warn_fwhm_email
                        and last_msg[-2] == 1) or (warn_centre_email
                                                   and last_msg[-1] == 1):
                    alert(subject, alert_msg, '*****@*****.**',
                          recipients)
                    dbc.insert_msg(
                        (t_now, alert_msg, 1, 1 * (not warn_fwhm_email),
                         1 * (not warn_centre_email)))
                    dbc.respond(0)
                    # FWHM and Centre back to normal
                elif ((last_msg[-3] == 0 or last_msg[-2] == 0
                       or last_msg[-1] == 0) and response == (0, )):
                    print(5)
                    #Keep sending messages until user responds
                    alert('Resending ' + subject, alert_msg,
                          '*****@*****.**', recipients)
            elif ((last_msg[-3] == 0 or last_msg[-2] == 0 or last_msg[-1] == 0)
                  and response == (0, )):
                print(5)
                #Keep sending messages until user responds
                alert('Resending ' + subject, alert_msg,
                      '*****@*****.**', recipients)

        del dbc
        print(alert_msg)
        time.sleep(downtime)