def _load_plugin(self, config, section): module_parts = section.split() module_name = module_parts[0] py_name = os.path.join(os.path.dirname(__file__), "plugins", module_name + ".py") py_dirname = os.path.join(os.path.dirname(__file__), "plugins", module_name, "__init__.py") if not os.path.exists(py_name) and not os.path.exists(py_dirname): logger.warning(msg(("noexist1", py_name))) return None return importlib.import_module('plugins.' + module_name)
def call_shutdown(self, message): # single shutdown guard if self.is_shutdown: return self.is_shutdown = True # self._set_status("%s %s" % (message, msg("shutdown"))) for cb in self.event_handlers.get("klippy:shutdown", []): try: cb() except error as e: logger.exception("Klippy Error: %s", e.msg()) self._set_status(e.status()) return except Exception as e: logger.exception("Unhandled exception during shutdown: %s" % str(e))
def cleanup(self, reason): logger.info("CLEANUP (%s)", reason) if reason == 'exit': pass elif reason == 'error': pass elif reason == 'restart': # TODO: in order to avoid reconfiguring, reactor must be revisited # to allow for resetting it without the need to re-register everything. #self.n.children["reactor"] = reactor.Reactor(self.hal, self.hal.node("reactor")) pass elif reason == 'reload': self.tree = None self.hal.get_reactor().cleanup() self.hal.cleanup() self.hal = None self.status_message = msg("startup") self.is_shutdown = False self.run_result = None self.event_handlers = {} else: raise error("Unknown exit reason (%s).", reason) return reason
for patient in cursor: if patient[3] == 1: if patient[2] != '': if patient[1].strftime('%p') == 'PM' or int(patient[1].strftime('%I')) >= reminder_hour: patient_cell_number.append(patient[2]) patient_appointment_time.append(patient[1]) x = 0 for number in patient_cell_number: appt_time = patient_appointment_time[x].strftime('%I:%M %p') msg = "This is a automated reminder of your appointment today scheduled for " + appt_time + " at " + address + " Please text back 'Yes' or call us at " + callbacknumber + " to confirm." print 'Sending reminder # ' + str(x + 1) + " of " + str(len(patient_cell_number)) try: text.msg(number, msg) log.write("Reminder Sent - Cell Number: " + number + " Time: " + patient_appointment_time[x].strftime('%I:%M %p'), file = 'Send-Log.html') except Exception as ex: log.write("Reminder Failure - Cell Number: " + number + " Time: " + patient_appointment_time[x].strftime('%I:%M %p') + ' Exception: ' + ex, file = 'Send-Log.html') #Wait a second between requests to be nice to twilio time.sleep(send_delay) x += 1 print "Patient reminders sent" log.write(str(x) + ' patient reminders have been sent. Waiting ', file = 'Overall.html') #Send out email alerts if enabled. if email_logs: log.email(file = 'Overall.html') #Wait a while to gather the recieved log and then send it to hq
for patient in cursor: if patient[3] == 1: if patient[2] != '': if patient[1].strftime('%p') == 'PM' or int( patient[1].strftime('%I')) >= reminder_hour: patient_cell_number.append(patient[2]) patient_appointment_time.append(patient[1]) x = 0 for number in patient_cell_number: appt_time = patient_appointment_time[x].strftime('%I:%M %p') msg = "This is a automated reminder of your appointment today scheduled for " + appt_time + " at " + address + " Please text back 'Yes' or call us at " + callbacknumber + " to confirm." print 'Sending reminder # ' + str(x + 1) + " of " + str( len(patient_cell_number)) try: text.msg(number, msg) log.write("Reminder Sent - Cell Number: " + number + " Time: " + patient_appointment_time[x].strftime('%I:%M %p'), file='Send-Log.html') except Exception as ex: log.write("Reminder Failure - Cell Number: " + number + " Time: " + patient_appointment_time[x].strftime('%I:%M %p') + ' Exception: ' + ex, file='Send-Log.html') #Wait a second between requests to be nice to twilio time.sleep(send_delay) x += 1 print "Patient reminders sent" log.write(str(x) + ' patient reminders have been sent. Waiting ', file='Overall.html')