messageboard-2020-06-04-0045.py
01234567890123456789012345678901234567890123456789012345678901234567890123456789









392393394395396397398399400401402403404405406407408409410411412413  414415416417418419420421422423424425426427428429430431432433434435436











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




        f.write('='*80+'\n')
        f.write(str(datetime.datetime.now(TZ))+'\n')
        f.write('\n')
      f.write(str(message)+'\n')
  except IOError:
    Log('Unable to append to ' + file)

  if rolling:
    existing_log_lines = ReadFile(file).splitlines()
    with open(rolling, 'w') as f:
      f.write('\n'.join(existing_log_lines[-ROLLING_LOG_SIZE:]))


def UpdateRollingLogSize(configuration):
  """Set the global rolling_log_line_count based on settings file."""
  if 'rolling_log_line_count' in configuration:
    global ROLLING_LOG_SIZE
    ROLLING_LOG_SIZE = configuration['rolling_log_line_count']


def LogTimes(times):
  """Logs elapsed time messages from a list tuples of epochs and identifiers."""


  msg = ''
  for n, t in enumerate(times[:-1]):
    msg += '%.2fs to get from reading %d to reading %s\n' % (
        times[n + 1][0] - t[0], t[1], times[n + 1][1])
  Log(msg)


def MaintainRollingWebLog(message, max_count, filename=None):
  """Maintains a rolling text file of at most max_count printed messages.

  Newest data at top and oldest data at the end, of at most max_count messages,
  where the delimiter between each message is identified by a special fixed string.

  Args:
    message: text message to prepend to the file.
    max_count: maximum number of messages to keep in the file; the max_count+1st message
      is deleted.
    filename: the file to update.
  """
  # can't define as a default parameter because ROLLING_MESSAGE_FILE name is potentially
  # modified based on SIMULATION flag
  if not filename:
    filename = ROLLING_MESSAGE_FILE




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





01234567890123456789012345678901234567890123456789012345678901234567890123456789









392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438











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




        f.write('='*80+'\n')
        f.write(str(datetime.datetime.now(TZ))+'\n')
        f.write('\n')
      f.write(str(message)+'\n')
  except IOError:
    Log('Unable to append to ' + file)

  if rolling:
    existing_log_lines = ReadFile(file).splitlines()
    with open(rolling, 'w') as f:
      f.write('\n'.join(existing_log_lines[-ROLLING_LOG_SIZE:]))


def UpdateRollingLogSize(configuration):
  """Set the global rolling_log_line_count based on settings file."""
  if 'rolling_log_line_count' in configuration:
    global ROLLING_LOG_SIZE
    ROLLING_LOG_SIZE = configuration['rolling_log_line_count']


def LogTimes(times, threshold=0):
  """Logs elapsed time messages from a list tuples of epochs and identifiers."""
  if threshold and times[-1][0] - times[0][0] < threshold:
    return
  msg = ''
  for n, t in enumerate(times[:-1]):
    msg += '%.2fs to get from reading %s to reading %s\n' % (
        times[n + 1][0] - t[0], t[1], times[n + 1][1])
  Log(msg)


def MaintainRollingWebLog(message, max_count, filename=None):
  """Maintains a rolling text file of at most max_count printed messages.

  Newest data at top and oldest data at the end, of at most max_count messages,
  where the delimiter between each message is identified by a special fixed string.

  Args:
    message: text message to prepend to the file.
    max_count: maximum number of messages to keep in the file; the max_count+1st message
      is deleted.
    filename: the file to update.
  """
  # can't define as a default parameter because ROLLING_MESSAGE_FILE name is potentially
  # modified based on SIMULATION flag
  if not filename:
    filename = ROLLING_MESSAGE_FILE




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