parameters: (self)
docstring: Manage all scheduled worker events
          This function limits itself to run only once every 60 seconds
  
          :return:
docstring_summary: Manage all scheduled worker events
          This function limits itself to run only once every 60 seconds
docstring_tokens: Manage all scheduled worker events This function limits itself to run only once every 60 seconds
function: def manage_event_schedules(self):
          """
          Manage all scheduled worker events
          This function limits itself to run only once every 60 seconds
  
          :return:
          """
  
          days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
          event_schedules = self.settings.get_worker_event_schedules()
          day_of_week = datetime.today().today().weekday()
          time_now = datetime.today().strftime('%H:%M')
  
          # Only run once a minute
          if time_now == self.last_schedule_run:
              return
  
          for event_schedule in event_schedules:
              schedule_time = event_schedule.get('schedule_time')
              # Ensure we have a schedule time
              if not schedule_time:
                  continue
              # Ensure the schedule time is now
              if time_now != schedule_time:
                  continue
  
              repetition = event_schedule.get('repetition')
              # Ensure we have a repetition
              if not repetition:
                  continue
  
              # Check if it should run
              if repetition == 'daily':
                  self.run_task(time_now, event_schedule.get('schedule_task'), event_schedule.get('schedule_worker_count'))
              elif repetition == 'weekday' and days[day_of_week] not in ['saturday', 'sunday']:
                  self.run_task(time_now, event_schedule.get('schedule_task'), event_schedule.get('schedule_worker_count'))
              elif repetition == 'weekend' and days[day_of_week] in ['saturday', 'sunday']:
                  self.run_task(time_now, event_schedule.get('schedule_task'), event_schedule.get('schedule_worker_count'))
              elif repetition == days[day_of_week]:
                  self.run_task(time_now, event_schedule.get('schedule_task'), event_schedule.get('schedule_worker_count'))
function_tokens: def manage_event_schedules ( self ) : days = [ 'monday' , 'tuesday' , 'wednesday' , 'thursday' , 'friday' , 'saturday' , 'sunday' ] event_schedules = self . settings . get_worker_event_schedules ( ) day_of_week = datetime . today ( ) . today ( ) . weekday ( ) time_now = datetime . today ( ) . strftime ( '%H:%M' ) # Only run once a minute if time_now == self . last_schedule_run : return for event_schedule in event_schedules : schedule_time = event_schedule . get ( 'schedule_time' ) # Ensure we have a schedule time if not schedule_time : continue # Ensure the schedule time is now if time_now != schedule_time : continue repetition = event_schedule . get ( 'repetition' ) # Ensure we have a repetition if not repetition : continue # Check if it should run if repetition == 'daily' : self . run_task ( time_now , event_schedule . get ( 'schedule_task' ) , event_schedule . get ( 'schedule_worker_count' ) ) elif repetition == 'weekday' and days [ day_of_week ] not in [ 'saturday' , 'sunday' ] : self . run_task ( time_now , event_schedule . get ( 'schedule_task' ) , event_schedule . get ( 'schedule_worker_count' ) ) elif repetition == 'weekend' and days [ day_of_week ] in [ 'saturday' , 'sunday' ] : self . run_task ( time_now , event_schedule . get ( 'schedule_task' ) , event_schedule . get ( 'schedule_worker_count' ) ) elif repetition == days [ day_of_week ] : self . run_task ( time_now , event_schedule . get ( 'schedule_task' ) , event_schedule . get ( 'schedule_worker_count' ) )