from lib.recurring_task import RecurringTask
from visualizers import visualizers

thread_lock_object = threading.Lock()


if not local_debug.is_debug():
    import RPi.GPIO as GPIO
    try:
        GPIO.setmode(GPIO.BOARD)
    except Exception:
        # ws281x causes an exception
        # when you try to set the board type
        pass

stations = configuration.get_airport_configs()
rgb_colors = colors_lib.get_colors()

renderer = renderer.get_renderer()


def update_weather_for_all_stations():
    """
    Updates the weather for all of the stations.
    This does not update the conditions or category.
    """

    weather.get_metars(stations.keys())


def __get_dimmed_color__(
from data_sources import weather
from lib.logger import Logger
from safe_logging import safe_log, safe_log_warning

python_logger = logging.getLogger("check_config_files")
python_logger.setLevel(logging.DEBUG)
LOGGER = Logger(python_logger)


def terminal_error(error_message):
    safe_log_warning(LOGGER, error_message)
    exit(0)


try:
    airport_render_config = configuration.get_airport_configs()
except Exception as e:
    terminal_error(
        'Unable to fetch the airport configuration. Please check the JSON files. Error={}'
        .format(e))

if len(airport_render_config) == 0:
    terminal_error('No airports found in the configuration file.')

stations_unable_to_fetch_weather = []

for station_id in airport_render_config:
    safe_log(LOGGER, 'Checking configuration for {}'.format(station_id))

    led_index = airport_render_config[station_id]