messageboard-2020-08-20-2144.py
01234567890123456789012345678901234567890123456789012345678901234567890123456789









546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504   55055506550755085509551055115512551355145515551655175518551955205521552255235524











                            <----SKIPPED LINES---->




  need to process the first of these, and can ignore subsequent ones, without
  any change of output in the simulation results. This function identifies
  whether the current active json changed from the prior one.

  Returns:
    Boolean - True if different (and processing needed), False if identical
  """
  if SIMULATION_COUNTER == 0:
    return True
  (this_json, unused_now) = DUMP_JSONS[SIMULATION_COUNTER]
  (last_json, unused_now) = DUMP_JSONS[SIMULATION_COUNTER - 1]
  return this_json != last_json


def CheckRebootNeeded(
    startup_time, message_queue, json_desc_dict, configuration):
  """Reboot based on duration instance has been running.

  Reboot needed in one of the following situations:
  - All quiet: if running for over 24 hours and all is quiet (message queue
    empty and no planes in radio).
  - Mostly quiet: if running for over 36 hours and message queue is empty and
    it's 3a.
  - Reboot requested via html form.

  Also checks if reset requested via html form.
  """
  reboot = False
  global SHUTDOWN_SIGNAL

  running_hours = (time.time() - startup_time) / SECONDS_IN_HOUR

  if (
      running_hours >= HOURS_IN_DAY and
      not message_queue and
      not json_desc_dict.get('radio_range_flights')):



    msg = 'All quiet reboot needed after running for %.2f hours' % running_hours
    SHUTDOWN_SIGNAL = msg
    Log(msg)
    reboot = True

  if (
      running_hours > HOURS_IN_DAY * 1.5 and
      not message_queue and
      int(EpochDisplayTime(time.time(), '%-H')) >= 3):
    msg = ('Early morning reboot needed after running for %.2f hours'
           % running_hours)
    SHUTDOWN_SIGNAL = msg
    Log(msg)
    reboot = True

  if 'soft_reboot' in configuration:
    msg = 'Soft reboot requested via web form'
    SHUTDOWN_SIGNAL = msg
    Log(msg)
    reboot = True




                            <----SKIPPED LINES---->





01234567890123456789012345678901234567890123456789012345678901234567890123456789









54695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527











                            <----SKIPPED LINES---->




  need to process the first of these, and can ignore subsequent ones, without
  any change of output in the simulation results. This function identifies
  whether the current active json changed from the prior one.

  Returns:
    Boolean - True if different (and processing needed), False if identical
  """
  if SIMULATION_COUNTER == 0:
    return True
  (this_json, unused_now) = DUMP_JSONS[SIMULATION_COUNTER]
  (last_json, unused_now) = DUMP_JSONS[SIMULATION_COUNTER - 1]
  return this_json != last_json


def CheckRebootNeeded(
    startup_time, message_queue, json_desc_dict, configuration):
  """Reboot based on duration instance has been running.

  Reboot needed in one of the following situations:
  - All quiet: if running for over 24 hours and all is quiet (message queue
    empty, no planes in radio, and backup not currently in process).
  - Mostly quiet: if running for over 36 hours and message queue is empty and
    it's 3a.
  - Reboot requested via html form.

  Also checks if reset requested via html form.
  """
  reboot = False
  global SHUTDOWN_SIGNAL

  running_hours = (time.time() - startup_time) / SECONDS_IN_HOUR

  if (
      running_hours >= HOURS_IN_DAY and
      not message_queue and
      not json_desc_dict.get('radio_range_flights') and
      # script /home/pi/splitflap/backup.sh creates temp file in this
      # directory; after it is copied to the NAS, it is deleted
      not os.listdir('/media/backup')):
    msg = 'All quiet reboot needed after running for %.2f hours' % running_hours
    SHUTDOWN_SIGNAL = msg
    Log(msg)
    reboot = True

  if (
      running_hours > HOURS_IN_DAY * 1.5 and
      not message_queue and
      int(EpochDisplayTime(time.time(), '%-H')) >= 3):
    msg = ('Early morning reboot needed after running for %.2f hours'
           % running_hours)
    SHUTDOWN_SIGNAL = msg
    Log(msg)
    reboot = True

  if 'soft_reboot' in configuration:
    msg = 'Soft reboot requested via web form'
    SHUTDOWN_SIGNAL = msg
    Log(msg)
    reboot = True




                            <----SKIPPED LINES---->