コード例 #1
0
    def print_scheduler_info(self):
        if self.count % 100 == 0:
            self.count = 0
            logging.info(" ========== Scheduling ==========")
            logging.info("-------- Geometry")
            logging.info("\t\t {} rows * {} cols".format(
                SchedulerState.get_rows(), SchedulerState.get_cols()))
            logging.info("-------- Disabled")
            logging.info("\t\t {}".format(SchedulerState.get_disabled()))
            logging.info("-------- Enable State")
            logging.info(SchedulerState.get_enable_state())
            logging.info("-------- Is Frontage Up?")
            logging.info(SchedulerState.is_frontage_on())
            logging.info("-------- Usable?")
            logging.info(SchedulerState.usable())
            logging.info("-------- Current App")
            logging.info(SchedulerState.get_current_app())
            logging.info('Forced App ? {}'.format(
                SchedulerState.get_forced_app()))
            logging.info("---------- Waiting Queue")
            logging.info(SchedulerState.get_user_app_queue())
            if SchedulerState.get_enable_state() == 'scheduled':
                logging.info("---------- Scheduled ON")
                logging.info(SchedulerState.get_scheduled_on_time().strftime(
                    "%d-%m-%Y %H:%M:%S UTC+00"))
                logging.info("---------- Scheduled OFF")
                logging.info(SchedulerState.get_scheduled_off_time().strftime(
                    "%d-%m-%Y %H:%M:%S UTC+00"))
                logging.info("---------- TIME NOW")
                logging.info(datetime.datetime.now().strftime(
                    "%d-%m-%Y %H:%M:%S UTC+00"))

        self.count += 1
コード例 #2
0
def status():
    c_app = SchedulerState.get_current_app()
    c_app_name = c_app.get('name', '') if c_app else ''
    return jsonify(is_usable=SchedulerState.usable(),
                   is_forced=SchedulerState.get_forced_app(),
                   current_app=c_app_name,
                   next_on_time=SchedulerState.get_scheduled_on_time().isoformat(),
                   state=SchedulerState.get_enable_state(),
                   current_time=datetime.datetime.now().isoformat())
コード例 #3
0
def admin_enabled_scheduler(user):
    state = g.data.get('state', 'on')
    if state not in ['on', 'off', 'scheduled']:
        abort(415, "Incorrect state")

    SchedulerState.set_enable_state(state)
    return jsonify(is_usable=SchedulerState.usable(),
                   is_forced=SchedulerState.get_forced_app(),
                   state=SchedulerState.get_enable_state(),
                   current_time=datetime.datetime.utcnow().isoformat())
コード例 #4
0
 def print_scheduler_info(self):
     if self.count % 10 == 0:
         self.count = 0
         print_flush(" ========== Scheduling ==========")
         print_flush("-------- Enable State")
         print_flush(SchedulerState.get_enable_state())
         print_flush("-------- Is Frontage Up?")
         print_flush(SchedulerState.is_frontage_on())
         print_flush("-------- Usable?")
         print_flush(SchedulerState.usable())
         print_flush("-------- Current App")
         print_flush(SchedulerState.get_current_app())
         print_flush('Forced App ?', SchedulerState.get_forced_app())
         print_flush("---------- Waiting Queue")
         print_flush(SchedulerState.get_user_app_queue())
         if SchedulerState.get_enable_state() == 'scheduled':
             print_flush("---------- Scheduled ON")
             print_flush(SchedulerState.get_scheduled_on_time())
             print_flush("---------- Scheduled OFF")
             print_flush(SchedulerState.get_scheduled_off_time())
     self.count += 1
コード例 #5
0
def status():
    c_app = SchedulerState.get_current_app()
    c_app_name = c_app.get('name', '') if c_app else ''
    on_time = SchedulerState.get_scheduled_on_time()
    if on_time is not None:
        on_time.isoformat()
    return jsonify(is_usable=SchedulerState.usable(),
                   is_forced=SchedulerState.get_forced_app(),
                   current_app=c_app_name,
                   next_on_time=on_time,
                   state=SchedulerState.get_enable_state(),
                   current_time=datetime.datetime.utcnow().isoformat(),
                   height=SchedulerState.get_rows(),
                   width=SchedulerState.get_cols(),
                   disabled=SchedulerState.get_disabled(),
                   version=SchedulerState.get_version())
コード例 #6
0
    def run_scheduler(self):
        # check usable value, based on ON/OFF AND if a forced app is running
        SchedulerState.set_usable((not SchedulerState.get_forced_app()) and SchedulerState.is_frontage_on())
        enable_state = SchedulerState.get_enable_state()
        if enable_state == 'scheduled':
            self.check_on_off_table()
        elif enable_state == 'on':
            SchedulerState.set_frontage_on(True)
        elif enable_state == 'off':
            SchedulerState.set_frontage_on(False)

        if SchedulerState.is_frontage_on():
            self.check_app_scheduler()
        else:
            # improvement : add check to avoid erase in each loop
            self.disable_frontage()
            self.frontage.erase_all()
コード例 #7
0
 def run(self):
     # we reset the value
     SchedulerState.set_frontage_on(True)
     SchedulerState.set_enable_state(SchedulerState.get_enable_state())
     logging.info('[SCHEDULER] Entering loop')
     self.frontage.start()
     try:
         while True:
             if SchedulerState.is_event_lock():
                 logging.info('Locked')
             else:
                 self.run_scheduler()
                 self.update_geometry()
                 self.print_scheduler_info()
             sleep(0.1)
     except:
         raise
     finally:
         pass
         self.frontage.close()
コード例 #8
0
 def run(self):
     # last_state = False
     # we reset the value
     SchedulerState.set_frontage_on(True)
     SchedulerState.set_enable_state(SchedulerState.get_enable_state())
     # usable = SchedulerState.usable()
     print_flush('[SCHEDULER] Entering loop')
     self.frontage.start()
     try:
         while True:
             if SchedulerState.is_event_lock():
                 print_flush('Locked')
             else:
                 self.run_scheduler()
                 self.print_scheduler_info()
             sleep(0.1)
     except:
         raise
     finally:
         pass
         self.frontage.close()