messageboard-2021-12-29-0952.py
01234567890123456789012345678901234567890123456789012345678901234567890123456789
1234567891011121314151617181920212223242526272829303132333435363738394041








621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661








#!/usr/bin/python3

import datetime
import io
import json
import math
import multiprocessing
import numbers
import os
import pickle
import queue
import re
import shutil
import signal
import statistics
import sys
import textwrap
import time

import bs4
import dateutil.relativedelta
import numpy
import matplotlib
import matplotlib.pyplot
import psutil
import pycurl
import pytz
import requests
import tzlocal
import unidecode

from constants import RASPBERRY_PI, MESSAGEBOARD_PATH, WEBSERVER_PATH

import arduino

if RASPBERRY_PI:
  import gpiozero  # pylint: disable=E0401
  import RPi.GPIO  # pylint: disable=E0401


VERBOSE = False  # additional messages logged




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




  except IOError:
    Log('Unable to maintain rolling log at ' + filename)


def UtcToLocalTimeDifference(timezone=TIMEZONE):
  """Calculates number of seconds between UTC and given timezone.

  Returns number of seconds between UTC and given timezone; if no timezone
  given, uses TIMEZONE defined in global variable.

  Args:
    timezone: string representing a valid pytz timezone in pytz.all_timezones.

  Returns:
    Integer number of seconds.
  """
  utcnow = pytz.timezone('utc').localize(datetime.datetime.utcnow())
  home_time = utcnow.astimezone(pytz.timezone(timezone)).replace(tzinfo=None)
  system_time = utcnow.astimezone(tzlocal.get_localzone()).replace(tzinfo=None)

  offset = dateutil.relativedelta.relativedelta(home_time, system_time)
  offset_seconds = offset.hours * SECONDS_IN_HOUR
  return offset_seconds


def IntersectionForTwoPaths(pos1, bearing1, pos2, bearing2):
  """Identifies the lat/lon intersection given starting points and bearings.

  Math provided at: http://www.movable-type.co.uk/scripts/latlong.html in the
  section: "Intersection of two paths given start points and bearings"; returns
  the latitude and longitude for the intersection.

  Args:
    pos1: a 2-tuple defining (lat, lon) in decimal degrees
    bearing1: bearing of pos1
    pos2: a 2-tuple defining (lat, lon) in decimal degrees
    bearing2: bearing of pos2

  Returns:
    Point of intersection as a 2-tuple defining (lat, lon) in decimal degrees
  """




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





01234567890123456789012345678901234567890123456789012345678901234567890123456789
1234567891011121314151617181920212223242526272829303132333435363738394041








621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661








#!/usr/bin/python3

import datetime
import io
import json
import math
import multiprocessing
import numbers
import os
import pickle
import queue
import re
import shutil
import signal
import statistics
import sys
import textwrap
import time

import bs4
import dateutils
import numpy
import matplotlib
import matplotlib.pyplot
import psutil
import pycurl
import pytz
import requests
import tzlocal
import unidecode

from constants import RASPBERRY_PI, MESSAGEBOARD_PATH, WEBSERVER_PATH

import arduino

if RASPBERRY_PI:
  import gpiozero  # pylint: disable=E0401
  import RPi.GPIO  # pylint: disable=E0401


VERBOSE = False  # additional messages logged




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




  except IOError:
    Log('Unable to maintain rolling log at ' + filename)


def UtcToLocalTimeDifference(timezone=TIMEZONE):
  """Calculates number of seconds between UTC and given timezone.

  Returns number of seconds between UTC and given timezone; if no timezone
  given, uses TIMEZONE defined in global variable.

  Args:
    timezone: string representing a valid pytz timezone in pytz.all_timezones.

  Returns:
    Integer number of seconds.
  """
  utcnow = pytz.timezone('utc').localize(datetime.datetime.utcnow())
  home_time = utcnow.astimezone(pytz.timezone(timezone)).replace(tzinfo=None)
  system_time = utcnow.astimezone(tzlocal.get_localzone()).replace(tzinfo=None)

  offset = dateutils.relativedelta(home_time, system_time)
  offset_seconds = offset.hours * SECONDS_IN_HOUR
  return offset_seconds


def IntersectionForTwoPaths(pos1, bearing1, pos2, bearing2):
  """Identifies the lat/lon intersection given starting points and bearings.

  Math provided at: http://www.movable-type.co.uk/scripts/latlong.html in the
  section: "Intersection of two paths given start points and bearings"; returns
  the latitude and longitude for the intersection.

  Args:
    pos1: a 2-tuple defining (lat, lon) in decimal degrees
    bearing1: bearing of pos1
    pos2: a 2-tuple defining (lat, lon) in decimal degrees
    bearing2: bearing of pos2

  Returns:
    Point of intersection as a 2-tuple defining (lat, lon) in decimal degrees
  """




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