diff --git a/etc/simulator.py b/etc/simulator.py index 1bbaee7..53cc572 100644 --- a/etc/simulator.py +++ b/etc/simulator.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # # Simulate meshing-around de K7MHI 2024 -from modules.log import * # Import the logger; ### --> If you are reading this put the script in the project root <-- ### +from modules.log import logger, getPrettyTime # Import the logger; ### --> If you are reading this put the script in the project root <-- ### import time import random diff --git a/mesh_bot.py b/mesh_bot.py index d9ed677..2804861 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -1,7 +1,6 @@ #!/usr/bin/python3 # Meshtastic Autoresponder MESH Bot # K7MHI Kelly Keeton 2025 - try: from pubsub import pub except ImportError: @@ -12,7 +11,8 @@ import asyncio import time # for sleep, get some when you can :) import random from datetime import datetime -from modules.log import * +from modules.log import logger, CustomFormatter, msgLogger +import modules.settings as my_settings from modules.system import * # list of commands to remove from the default list for DM only @@ -358,16 +358,15 @@ def handle_emergency(message_from_id, deviceID, message): return EMERGENCY_RESPONSE def handle_motd(message, message_from_id, isDM): - global MOTD - msg = MOTD + msg = my_settings.MOTD isAdmin = isNodeAdmin(message_from_id) if "?" in message: msg = "Message of the day, set with 'motd $ HelloWorld!'" elif "$" in message and isAdmin: - motd = message.split("$")[1] - MOTD = motd.rstrip() - logger.debug(f"System: {message_from_id} temporarly changed MOTD: {MOTD}") - msg = "MOTD changed to: " + MOTD + my_settings.MOTD = message.split("$")[1] + my_settings.MOTD = my_settings.MOTD.rstrip() + logger.debug(f"System: {message_from_id} temporarly changed my_settings.MOTD: {my_settings.MOTD}") + msg = "my_settings.MOTD changed to: " + my_settings.MOTD return msg def handle_echo(message, message_from_id, deviceID, isDM, channel_number): @@ -1879,8 +1878,8 @@ async def start_rx(): if rssEnable: logger.debug(f"System: RSS Feed Reader Enabled for feeds: {rssFeedNames}") - if motd_enabled: - logger.debug(f"System: MOTD Enabled using {MOTD} scheduler:{schedulerMotd}") + if my_settings.MOTD_enabled: + logger.debug(f"System: MOTD Enabled using {my_settings.MOTD} scheduler:{my_settings.schedulerMOTD}") if sentry_enabled: logger.debug(f"System: Sentry Mode Enabled {sentry_radius}m radius reporting to channel:{secure_channel} requestLOC:{reqLocationEnabled}") @@ -1958,8 +1957,18 @@ async def start_rx(): # setup the scheduler from modules.scheduler import setup_scheduler await setup_scheduler( - schedulerMotd, MOTD, schedulerMessage, schedulerChannel, schedulerInterface, - schedulerValue, schedulerTime, schedulerInterval, logger, BroadcastScheduler + scheduler( + my_settings.MOTD, + my_settings.MOTD, + my_settings.schedulerMessage, + my_settings.schedulerChannel, + my_settings.schedulerInterface, + my_settings.schedulerValue, + my_settings.schedulerTime, + my_settings.schedulerInterval, + logger, + my_settings.BroadcastScheduler + ) ) # here we go loopty loo diff --git a/modules/bbstools.py b/modules/bbstools.py index 8300f9e..ae752cf 100644 --- a/modules/bbstools.py +++ b/modules/bbstools.py @@ -2,7 +2,8 @@ # K7MHI Kelly Keeton 2024 import pickle # pip install pickle -from modules.log import * +from modules.log import logger +from modules.settings import bbs_admin_list, bbs_ban_list, MESSAGE_CHUNK_SIZE, bbs_link_enabled, bbs_link_whitelist, responseDelay import time from datetime import datetime diff --git a/modules/checklist.py b/modules/checklist.py index d7f0030..8418a19 100644 --- a/modules/checklist.py +++ b/modules/checklist.py @@ -2,7 +2,8 @@ # K7MHI Kelly Keeton 2024 import sqlite3 -from modules.log import * +from modules.log import logger +from modules.settings import checklist_db, reverse_in_out, bbs_ban_list import time trap_list_checklist = ("checkin", "checkout", "checklist", "purgein", "purgeout") diff --git a/modules/filemon.py b/modules/filemon.py index 07c2da9..ebd00f0 100644 --- a/modules/filemon.py +++ b/modules/filemon.py @@ -1,7 +1,17 @@ # File monitor module for the meshing-around bot # 2024 Kelly Keeton K7MHI -from modules.log import * +from modules.log import logger +from modules.settings import ( + file_monitor_file_path, + news_file_path, + news_random_line_only, + allowXcmd, + bbs_admin_list, + xCmd2factorEnabled, + xCmd2factor_timeout, + enable_runShellCmd + ) import asyncio import random import os diff --git a/modules/games/blackjack.py b/modules/games/blackjack.py index e9e3155..ba1b3e3 100644 --- a/modules/games/blackjack.py +++ b/modules/games/blackjack.py @@ -2,7 +2,8 @@ # Adapted for Meshtastic mesh-bot by K7MHI Kelly Keeton 2024 from random import choices, shuffle -from modules.log import * +from modules.log import logger +from modules.settings import jackTracker import time import pickle diff --git a/modules/games/dopewar.py b/modules/games/dopewar.py index 8537275..b7e9e83 100644 --- a/modules/games/dopewar.py +++ b/modules/games/dopewar.py @@ -4,7 +4,7 @@ import random import time import pickle -from modules.log import * +from modules.log import logger # Global variables total_days = 7 # number of days or rotations the player has to play diff --git a/modules/games/golfsim.py b/modules/games/golfsim.py index 97e0250..0ea1489 100644 --- a/modules/games/golfsim.py +++ b/modules/games/golfsim.py @@ -4,7 +4,7 @@ import random import time import pickle -from modules.log import * +from modules.log import logger # Clubs setup driver_distances = list(range(230, 280, 5)) diff --git a/modules/games/hamtest.py b/modules/games/hamtest.py index 60d840a..77b5f12 100644 --- a/modules/games/hamtest.py +++ b/modules/games/hamtest.py @@ -9,7 +9,7 @@ import json import random import os -from modules.log import * +from modules.log import logger class HamTest: def __init__(self): diff --git a/modules/games/hangman.py b/modules/games/hangman.py index 9d07d53..b763845 100644 --- a/modules/games/hangman.py +++ b/modules/games/hangman.py @@ -1,5 +1,5 @@ # Written for Meshtastic mesh-bot by ZR1RF Johannes le Roux 2025 -from modules.log import * +from modules.log import logger, getPrettyTime import os import json import random diff --git a/modules/games/joke.py b/modules/games/joke.py index a21015f..9e7f97d 100644 --- a/modules/games/joke.py +++ b/modules/games/joke.py @@ -3,7 +3,7 @@ # As a Ham, is this obsecuring the meaning of the joke? Or is it enhancing it? from dadjokes import Dadjoke # pip install dadjokes import random -from modules.log import * +from modules.log import logger, getPrettyTime lameJokes = [ "Why don't scientists trust atoms? Because they make up everything!", diff --git a/modules/games/lemonade.py b/modules/games/lemonade.py index f349b96..ed986ab 100644 --- a/modules/games/lemonade.py +++ b/modules/games/lemonade.py @@ -6,8 +6,8 @@ from random import randrange, uniform # random numbers from types import SimpleNamespace # namespaces support import pickle # pickle file support import time # time functions -from modules.log import * # mesh-bot logging - +from modules.log import logger # mesh-bot logging +from modules.system import lemonadeTracker # player tracking import locale # culture specific locale import math # math functions import re # regular expressions diff --git a/modules/games/meshtrekker.py b/modules/games/meshtrekker.py index 84ee098..a648039 100644 --- a/modules/games/meshtrekker.py +++ b/modules/games/meshtrekker.py @@ -12,7 +12,7 @@ Game Rules: """ import pickle -from modules.log import * +from modules.log import logger, getPrettyTime from datetime import datetime, timedelta from geopy.distance import geodesic diff --git a/modules/games/mmind.py b/modules/games/mmind.py index 5f155a4..eaed862 100644 --- a/modules/games/mmind.py +++ b/modules/games/mmind.py @@ -4,7 +4,8 @@ import random import time import pickle -from modules.log import * +from modules.log import logger +from modules.system import mindTracker def chooseDifficultyMMind(message): usrInput = message.lower() diff --git a/modules/games/quiz.py b/modules/games/quiz.py index 2039b99..2fed976 100644 --- a/modules/games/quiz.py +++ b/modules/games/quiz.py @@ -11,7 +11,8 @@ import json import os import random -from modules.log import * +from modules.log import logger +from modules.settings import bbs_admin_list QUIZ_JSON = os.path.join(os.path.dirname(__file__), '../', '../', 'data', 'quiz_questions.json') QUIZMASTER_ID = bbs_admin_list diff --git a/modules/games/tictactoe.py b/modules/games/tictactoe.py index 0d46709..2f2129c 100644 --- a/modules/games/tictactoe.py +++ b/modules/games/tictactoe.py @@ -1,13 +1,13 @@ # Tic-Tac-Toe game for Meshtastic mesh-bot # Board positions chosen by numbers 1-9 # 2025 -from modules.log import * import random import time +import modules.settings as my_settings # to (max), molly and jake, I miss you both so much. -if disable_emojis_in_games: +if my_settings.disable_emojis_in_games: X = "X" O = "O" else: @@ -65,7 +65,7 @@ class TicTacToe: row = "" for j in range(3): pos = i * 3 + j - if disable_emojis_in_games: + if my_settings.disable_emojis_in_games: cell = b[pos] if b[pos] != " " else str(pos + 1) else: cell = b[pos] if b[pos] != " " else f" {str(pos + 1)} " @@ -74,7 +74,6 @@ class TicTacToe: row += " | " board_str += row if i < 2: - #board_str += "\n-+-+-\n" board_str += "\n" return board_str + "\n" diff --git a/modules/games/videopoker.py b/modules/games/videopoker.py index 1bb4b9c..c93f6e1 100644 --- a/modules/games/videopoker.py +++ b/modules/games/videopoker.py @@ -3,7 +3,7 @@ import random import time import pickle -from modules.log import * +from modules.log import logger, getPrettyTime vpStartingCash = 20 # Define the Card class diff --git a/modules/games/wodt.py b/modules/games/wodt.py index 243d8c1..5b043c0 100644 --- a/modules/games/wodt.py +++ b/modules/games/wodt.py @@ -1,6 +1,6 @@ # python word of the day game module for meshing-around bot # 2025 K7MHI Kelly Keeton -from modules.log import * +from modules.log import logger, getPrettyTime import random import json import os diff --git a/modules/globalalert.py b/modules/globalalert.py index 4c6a592..7b4d773 100644 --- a/modules/globalalert.py +++ b/modules/globalalert.py @@ -2,12 +2,13 @@ # K7MHI Kelly Keeton 2024 import json # pip install json -from geopy.geocoders import Nominatim # pip install geopy -import maidenhead as mh # pip install maidenhead +#from geopy.geocoders import Nominatim # pip install geopy +#import maidenhead as mh # pip install maidenhead import requests # pip install requests import bs4 as bs # pip install beautifulsoup4 -import xml.dom.minidom -from modules.log import * +#import xml.dom.minidom +from modules.log import logger +from modules.settings import urlTimeoutSeconds, NO_ALERTS, myRegionalKeysDE trap_list_location_eu = ("ukalert", "ukwx", "ukflood") trap_list_location_de = ("dealert", "dewx", "deflood") @@ -22,7 +23,7 @@ def get_govUK_alerts(lat, lon): alert = soup.find('h2', class_='govuk-heading-m', id='alert-status') except Exception as e: logger.warning("Error getting UK alerts: " + str(e)) - return NO_ALERTS + return if alert: return "🚨" + alert.get_text(strip=True) diff --git a/modules/gpio.py b/modules/gpio.py index d158942..3beeb14 100644 --- a/modules/gpio.py +++ b/modules/gpio.py @@ -7,7 +7,7 @@ # https://pythonhosted.org/RPIO/ import RPIO -from modules.log import * +from modules.log import logger, getPrettyTime trap_list_gpio = ("gpio", "pin", "relay", "switch", "pwm") # set up input channel without pull-up diff --git a/modules/llm.py b/modules/llm.py index 5810039..81d6aad 100644 --- a/modules/llm.py +++ b/modules/llm.py @@ -2,7 +2,8 @@ # LLM Module for meshing-around # This module is used to interact with LLM API to generate responses to user input # K7MHI Kelly Keeton 2024 -from modules.log import * +from modules.log import logger +from modules.settings import llmModel, ollamaHostName, rawLLMQuery # Ollama Client # https://github.com/ollama/ollama/blob/main/docs/faq.md#how-do-i-configure-ollama-server diff --git a/modules/locationdata.py b/modules/locationdata.py index 27082b2..357df92 100644 --- a/modules/locationdata.py +++ b/modules/locationdata.py @@ -6,14 +6,15 @@ from geopy.geocoders import Nominatim # pip install geopy import maidenhead as mh # pip install maidenhead import requests # pip install requests import bs4 as bs # pip install beautifulsoup4 -import xml.dom.minidom +import xml.dom.minidom # used for parsing XML +import xml.parsers.expat # used for parsing XML from datetime import datetime -from modules.log import * +from modules.log import logger +import modules.settings as my_settings import math import csv import os - trap_list_location = ("whereami", "wx", "wxa", "wxalert", "rlist", "ea", "ealert", "riverflow", "valert", "earthquake", "howfar", "map",) def where_am_i(lat=0, lon=0, short=False, zip=False): @@ -23,7 +24,7 @@ def where_am_i(lat=0, lon=0, short=False, zip=False): if int(float(lat)) == 0 and int(float(lon)) == 0: logger.error("Location: No GPS data, try sending location") - return NO_DATA_NOGPS + return my_settings.NO_DATA_NOGPS # initialize Nominatim API geolocator = Nominatim(user_agent="mesh-bot") @@ -43,7 +44,7 @@ def where_am_i(lat=0, lon=0, short=False, zip=False): whereIam = location.raw['address'].get('postcode', '') return whereIam - if float(lat) == latitudeValue and float(lon) == longitudeValue: + if float(lat) == my_settings.latitudeValue and float(lon) == my_settings.longitudeValue: # redacted address when no GPS and using default location location = geolocator.reverse(str(lat) + ", " + str(lon)) address = location.raw['address'] @@ -72,7 +73,7 @@ def where_am_i(lat=0, lon=0, short=False, zip=False): return whereIam except Exception as e: logger.debug("Location:Error fetching location data with whereami, likely network error") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA def getRepeaterBook(lat=0, lon=0): grid = mh.to_maiden(float(lat), float(lon)) @@ -90,7 +91,7 @@ def getRepeaterBook(lat=0, lon=0): try: msg = '' user_agent = {'User-agent': 'Mozilla/5.0'} - response = requests.get(repeater_url, headers=user_agent, timeout=urlTimeoutSeconds) + response = requests.get(repeater_url, headers=user_agent, timeout=my_settings.urlTimeoutSeconds) if response.status_code!=200: logger.error(f"Location:Error fetching repeater data from {repeater_url} with status code {response.status_code}") soup = bs.BeautifulSoup(response.text, 'html.parser') @@ -129,13 +130,13 @@ def getArtSciRepeaters(lat=0, lon=0): #grid = mh.to_maiden(float(lat), float(lon)) repeaters = [] zipCode = where_am_i(lat, lon, zip=True) - if zipCode == NO_DATA_NOGPS or zipCode == ERROR_FETCHING_DATA: + if zipCode == my_settings.NO_DATA_NOGPS or zipCode == my_settings.ERROR_FETCHING_DATA: return zipCode if zipCode.isnumeric(): try: artsci_url = f"http://www.artscipub.com/mobile/showstate.asp?zip={zipCode}" - response = requests.get(artsci_url, timeout=urlTimeoutSeconds) + response = requests.get(artsci_url, timeout=my_settings.urlTimeoutSeconds) if response.status_code!=200: logger.error(f"Location:Error fetching data from {artsci_url} with status code {response.status_code}") soup = bs.BeautifulSoup(response.text, 'html.parser') @@ -177,16 +178,16 @@ def get_NOAAtide(lat=0, lon=0): station_id = "" location = lat,lon if float(lat) == 0 and float(lon) == 0: - lat = latitudeValue - lon = longitudeValue + lat = my_settings.latitudeValue + lon = my_settings.longitudeValue station_lookup_url = "https://api.tidesandcurrents.noaa.gov/mdapi/prod/webapi/tidepredstations.json?lat=" + str(lat) + "&lon=" + str(lon) + "&radius=50" try: - station_data = requests.get(station_lookup_url, timeout=urlTimeoutSeconds) + station_data = requests.get(station_lookup_url, timeout=my_settings.urlTimeoutSeconds) if station_data.ok: station_json = station_data.json() else: logger.error("Location:Error fetching tide station table from NOAA") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA if station_json['stationList'] == [] or station_json['stationList'] is None: logger.error("Location:No tide station found") @@ -196,26 +197,26 @@ def get_NOAAtide(lat=0, lon=0): except (requests.exceptions.RequestException, json.JSONDecodeError): logger.error("Location:Error fetching tide station table from NOAA") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA station_url = "https://api.tidesandcurrents.noaa.gov/api/prod/datagetter?date=today&time_zone=lst_ldt&datum=MLLW&product=predictions&interval=hilo&format=json&station=" + station_id - if use_metric: + if my_settings.use_metric: station_url += "&units=metric" else: station_url += "&units=english" try: - tide_data = requests.get(station_url, timeout=urlTimeoutSeconds) + tide_data = requests.get(station_url, timeout=my_settings.urlTimeoutSeconds) if tide_data.ok: tide_json = tide_data.json() else: logger.error("Location:Error fetching tide data from NOAA") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA except (requests.exceptions.RequestException, json.JSONDecodeError): logger.error("Location:Error fetching tide data from NOAA") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA tide_data = tide_json['predictions'] @@ -225,7 +226,7 @@ def get_NOAAtide(lat=0, lon=0): tide_table = "Tide Data for " + tide_date + "\n" for tide in tide_data: tide_time = tide['t'].split(" ")[1] - if not zuluTime: + if not my_settings.zuluTime: # convert to 12 hour clock if int(tide_time.split(":")[0]) > 12: tide_time = str(int(tide_time.split(":")[0]) - 12) + ":" + tide_time.split(":")[1] + " PM" @@ -242,11 +243,11 @@ def get_NOAAweather(lat=0, lon=0, unit=0): weather = "" location = lat,lon if float(lat) == 0 and float(lon) == 0: - lat = latitudeValue - lon = longitudeValue + lat = my_settings.latitudeValue + lon = my_settings.longitudeValue # get weather data from NOAA units for metric unit = 1 is metric - if use_metric: + if my_settings.use_metric: unit = 1 logger.debug("Location: new API metric units not implemented yet") @@ -254,29 +255,29 @@ def get_NOAAweather(lat=0, lon=0, unit=0): weather_api = "https://api.weather.gov/points/" + str(lat) + "," + str(lon) # extract the "forecast": property from the JSON response try: - weather_data = requests.get(weather_api, timeout=urlTimeoutSeconds) + weather_data = requests.get(weather_api, timeout=my_settings.urlTimeoutSeconds) if not weather_data.ok: logger.warning("Location:Error fetching weather data from NOAA for location") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA except Exception: logger.warning(f"Location:Error fetching weather data error: {Exception}") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA # get the forecast URL from the JSON response weather_json = weather_data.json() forecast_url = weather_json['properties']['forecast'] try: - forecast_data = requests.get(forecast_url, timeout=urlTimeoutSeconds) + forecast_data = requests.get(forecast_url, timeout=my_settings.urlTimeoutSeconds) if not forecast_data.ok: logger.warning("Location:Error fetching weather forecast from NOAA") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA except Exception: logger.warning(f"Location:Error fetching weather data error: {Exception}") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA # from periods, get the detailedForecast from number of days in NOAAforecastDuration forecast_json = forecast_data.json() forecast = forecast_json['properties']['periods'] - for day in forecast[:forecastDuration]: + for day in forecast[:my_settings.forecastDuration]: # abreviate the forecast weather += abbreviate_noaa(day['name']) + ": " + abbreviate_noaa(day['detailedForecast']) + "\n" @@ -286,7 +287,7 @@ def get_NOAAweather(lat=0, lon=0, unit=0): # get any alerts and return the count alerts = getWeatherAlertsNOAA(lat, lon) - if alerts == ERROR_FETCHING_DATA or alerts == NO_DATA_NOGPS or alerts == NO_ALERTS: + if alerts == my_settings.ERROR_FETCHING_DATA or alerts == my_settings.NO_DATA_NOGPS or alerts == my_settings.NO_ALERTS: alert = "" alert_num = 0 else: @@ -395,36 +396,36 @@ def getWeatherAlertsNOAA(lat=0, lon=0, useDefaultLatLon=False): alerts = "" location = lat,lon if useDefaultLatLon: - lat = latitudeValue - lon = longitudeValue + lat = my_settings.latitudeValue + lon = my_settings.longitudeValue if float(lat) == 0 and float(lon) == 0 and not useDefaultLatLon: - return NO_DATA_NOGPS + return my_settings.NO_DATA_NOGPS alert_url = "https://api.weather.gov/alerts/active.atom?point=" + str(lat) + "," + str(lon) #alert_url = "https://api.weather.gov/alerts/active.atom?area=WA" #logger.debug("Location:Fetching weather alerts from NOAA for " + str(lat) + ", " + str(lon)) try: - alert_data = requests.get(alert_url, timeout=urlTimeoutSeconds) + alert_data = requests.get(alert_url, timeout=my_settings.urlTimeoutSeconds) if not alert_data.ok: logger.warning("Location:Error fetching weather alerts from NOAA") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA except Exception: logger.warning(f"Location:Error fetching weather data error: {Exception}") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA alerts = "" alertxml = xml.dom.minidom.parseString(alert_data.text) for i in alertxml.getElementsByTagName("entry"): title = i.getElementsByTagName("title")[0].childNodes[0].nodeValue area_desc = i.getElementsByTagName("cap:areaDesc")[0].childNodes[0].nodeValue - if enableExtraLocationWx: + if my_settings.enableExtraLocationWx: alerts += f"{title}. {area_desc.replace(' ', '')}\n" else: alerts += f"{title}\n" if alerts == "" or alerts == None: - return NO_ALERTS + return my_settings.NO_ALERTS # trim off last newline if alerts[-1] == "\n": @@ -437,23 +438,23 @@ def getWeatherAlertsNOAA(lat=0, lon=0, useDefaultLatLon=False): alerts = abbreviate_noaa(alerts) # return the first ALERT_COUNT alerts - data = "\n".join(alerts.split("\n")[:numWxAlerts]), alert_num + data = "\n".join(alerts.split("\n")[:my_settings.numWxAlerts]), alert_num return data wxAlertCacheNOAA = "" def alertBrodcastNOAA(): # get the latest weather alerts and broadcast them if there are any global wxAlertCacheNOAA - currentAlert = getWeatherAlertsNOAA(latitudeValue, longitudeValue) + currentAlert = getWeatherAlertsNOAA(my_settings.latitudeValue, my_settings.longitudeValue) # check if any reason to discard the alerts - if currentAlert == ERROR_FETCHING_DATA or currentAlert == NO_DATA_NOGPS: + if currentAlert == my_settings.ERROR_FETCHING_DATA or currentAlert == my_settings.NO_DATA_NOGPS: return False - elif currentAlert == NO_ALERTS: + elif currentAlert == my_settings.NO_ALERTS: wxAlertCacheNOAA = "" return False - if ignoreEASenable: + if my_settings.ignoreEASenable: # check if the alert is in the ignoreEAS list - for word in ignoreEASwords: + for word in my_settings.ignoreEASwords: if word.lower() in currentAlert[0].lower(): logger.debug(f"Location:Ignoring NOAA Alert: {currentAlert[0]} containing {word}") return False @@ -471,21 +472,21 @@ def getActiveWeatherAlertsDetailNOAA(lat=0, lon=0): alerts = "" location = lat,lon if float(lat) == 0 and float(lon) == 0: - lat = latitudeValue - lon = longitudeValue + lat = my_settings.latitudeValue + lon = my_settings.longitudeValue alert_url = "https://api.weather.gov/alerts/active.atom?point=" + str(lat) + "," + str(lon) #alert_url = "https://api.weather.gov/alerts/active.atom?area=WA" #logger.debug("Location:Fetching weather alerts detailed from NOAA for " + str(lat) + ", " + str(lon)) try: - alert_data = requests.get(alert_url, timeout=urlTimeoutSeconds) + alert_data = requests.get(alert_url, timeout=my_settings.urlTimeoutSeconds) if not alert_data.ok: logger.warning("Location:Error fetching weather alerts from NOAA") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA except Exception: logger.warning(f"Location:Error fetching weather data error: {Exception}") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA alerts = "" alertxml = xml.dom.minidom.parseString(alert_data.text) @@ -505,10 +506,10 @@ def getActiveWeatherAlertsDetailNOAA(lat=0, lon=0): alerts = abbreviate_noaa(alerts) # trim the alerts to the first ALERT_COUNT - alerts = alerts.split("\n***\n")[:numWxAlerts] + alerts = alerts.split("\n***\n")[:my_settings.numWxAlerts] if alerts == "" or alerts == ['']: - return NO_ALERTS + return my_settings.NO_ALERTS # trim off last newline if alerts[-1] == "\n": @@ -530,13 +531,13 @@ def getIpawsAlert(lat=0, lon=0, shortAlerts = False): # get the alerts from FEMA try: - alert_data = requests.get(alert_url, timeout=urlTimeoutSeconds) + alert_data = requests.get(alert_url, timeout=my_settings.urlTimeoutSeconds) if not alert_data.ok: logger.warning(f"System: iPAWS fetching IPAWS alerts from FEMA (HTTP {alert_data.status_code})") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA except Exception as e: logger.warning(f"System: iPAWS fetching IPAWS alerts from FEMA failed: {e}") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA # main feed bulletins alertxml = xml.dom.minidom.parseString(alert_data.text) @@ -558,13 +559,13 @@ def getIpawsAlert(lat=0, lon=0, shortAlerts = False): continue # check if it matches your list - if stateFips not in myStateFIPSList: - #logger.debug(f"Skipping FEMA record link {link} with stateFIPS code of: {stateFips} because it doesn't match our StateFIPSList {myStateFIPSList}") + if stateFips not in my_settings.myStateFIPSList: + #logger.debug(f"Skipping FEMA record link {link} with stateFIPS code of: {stateFips} because it doesn't match our StateFIPSList {my_settings.myStateFIPSList}") continue # skip to next entry try: # get the linked alert data from FEMA - linked_data = requests.get(link, timeout=urlTimeoutSeconds) + linked_data = requests.get(link, timeout=my_settings.urlTimeoutSeconds) if not linked_data.ok or not linked_data.text.strip(): # if the linked data is not ok, skip this alert #logger.warning(f"System: iPAWS Error fetching linked alert data from {link}") @@ -616,14 +617,14 @@ def getIpawsAlert(lat=0, lon=0, shortAlerts = False): continue # check if the alert is for the SAME location, if wanted keep alert - if (sameVal in mySAMEList) or (geocode_value in mySAMEList) or mySAMEList == ['']: + if (sameVal in my_settings.mySAMEList) or (geocode_value in my_settings.mySAMEList) or my_settings.mySAMEList == ['']: ignore_alert = False - if ignoreFEMAenable: + if my_settings.ignoreFEMAenable: ignore_alert = any( word.lower() in headline.lower() - for word in ignoreFEMAwords) + for word in my_settings.ignoreFEMAwords) if ignore_alert: - logger.debug(f"System: Filtering FEMA Alert by WORD: {headline} containing one of {ignoreFEMAwords} at {areaDesc}") + logger.debug(f"System: Filtering FEMA Alert by WORD: {headline} containing one of {my_settings.ignoreFEMAwords} at {areaDesc}") if ignore_alert: continue @@ -643,16 +644,16 @@ def getIpawsAlert(lat=0, lon=0, shortAlerts = False): # return the numWxAlerts of alerts if len(alerts) > 0: - for alertItem in alerts[:numWxAlerts]: + for alertItem in alerts[:my_settings.numWxAlerts]: if shortAlerts: alert += abbreviate_noaa(f"🚨FEMA Alert: {alertItem['headline']}") else: alert += abbreviate_noaa(f"🚨FEMA Alert: {alertItem['headline']}\n{alertItem['description']}") # add a newline if not the last alert - if alertItem != alerts[:numWxAlerts][-1]: + if alertItem != alerts[:my_settings.numWxAlerts][-1]: alert += "\n" else: - alert = NO_ALERTS + alert = my_settings.NO_ALERTS return alert @@ -665,22 +666,22 @@ def get_flood_noaa(lat=0, lon=0, uid=None): headers = {'accept': 'application/json'} if not uid: logger.warning(f"Location:No flood gauge data found for UID {uid}") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA try: - response = requests.get(api_url + str(uid), headers=headers, timeout=urlTimeoutSeconds) + response = requests.get(api_url + str(uid), headers=headers, timeout=my_settings.urlTimeoutSeconds) if not response.ok: logger.warning(f"Location:Error fetching flood gauge data from NOAA for {uid} (HTTP {response.status_code})") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA data = response.json() if not data or 'status' not in data: logger.warning(f"Location:No flood gauge data found for UID {uid}") return "No flood gauge data found" except requests.exceptions.RequestException as e: logger.warning(f"Location:Error fetching flood gauge data from: {api_url}{uid} ({e})") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA except Exception as e: logger.warning(f"Location:Unexpected error: {e}") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA # extract values from JSON safely try: @@ -696,35 +697,35 @@ def get_flood_noaa(lat=0, lon=0, uid=None): return flood_data except Exception as e: logger.debug(f"Location:Error extracting flood gauge data from NOAA for {uid}: {e}") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA def get_volcano_usgs(lat=0, lon=0): alerts = '' if lat == 0 and lon == 0: - lat = latitudeValue - lon = longitudeValue + lat = my_settings.latitudeValue + lon = my_settings.longitudeValue # get the latest volcano alert from USGS from CAP feed usgs_volcano_url = "https://volcanoes.usgs.gov/hans-public/api/volcano/getCapElevated" try: - volcano_data = requests.get(usgs_volcano_url, timeout=urlTimeoutSeconds) + volcano_data = requests.get(usgs_volcano_url, timeout=my_settings.urlTimeoutSeconds) if not volcano_data.ok: logger.warning("System: Issue with fetching volcano alerts from USGS") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA except (requests.exceptions.RequestException): logger.warning("System: Issue with fetching volcano alerts from USGS") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA volcano_json = volcano_data.json() # extract alerts from main feed if volcano_json and isinstance(volcano_json, list): for alert in volcano_json: # check ignore list - if ignoreUSGSEnable: - for word in ignoreUSGSwords: + if my_settings.ignoreUSGSEnable: + for word in my_settings.ignoreUSGSwords: if word.lower() in alert['volcano_name_appended'].lower(): logger.debug(f"System: Ignoring USGS Alert: {alert['volcano_name_appended']} containing {word}") continue # check if the alert lat long is within the range of bot latitudeValue and longitudeValue - if (alert['latitude'] >= latitudeValue - 10 and alert['latitude'] <= latitudeValue + 10) and (alert['longitude'] >= longitudeValue - 10 and alert['longitude'] <= longitudeValue + 10): + if (alert['latitude'] >= my_settings.latitudeValue - 10 and alert['latitude'] <= my_settings.latitudeValue + 10) and (alert['longitude'] >= my_settings.longitudeValue - 10 and alert['longitude'] <= my_settings.longitudeValue + 10): volcano_name = alert['volcano_name_appended'] alert_level = alert['alert_level'] color_code = alert['color_code'] @@ -737,9 +738,9 @@ def get_volcano_usgs(lat=0, lon=0): continue else: logger.debug("Location:Error fetching volcano data from USGS") - return NO_ALERTS + return my_settings.NO_ALERTS if alerts == "": - return NO_ALERTS + return my_settings.NO_ALERTS # trim off last newline if alerts[-1] == "\n": alerts = alerts[:-1] @@ -750,13 +751,13 @@ def get_volcano_usgs(lat=0, lon=0): def get_nws_marine(zone, days=3): # forecast from NWS coastal products try: - marine_pz_data = requests.get(zone, timeout=urlTimeoutSeconds) + marine_pz_data = requests.get(zone, timeout=my_settings.urlTimeoutSeconds) if not marine_pz_data.ok: logger.warning(f"Location:Error fetching NWS Marine data (HTTP {marine_pz_data.status_code})") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA except requests.exceptions.RequestException as e: logger.warning(f"Location:Error fetching NWS Marine data: {e}") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA marine_pz_data = marine_pz_data.text todayDate = datetime.now().strftime("%Y%m%d") @@ -766,13 +767,13 @@ def get_nws_marine(zone, days=3): expires_date = expires[:8] if expires_date < todayDate: logger.debug("Location: NWS Marine PZ data expired") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA except Exception as e: logger.debug(f"Location: NWS Marine PZ data parse error: {e}") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA else: logger.debug("Location: NWS Marine PZ data not valid or empty") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA # process the marine forecast data marine_pzz_lines = marine_pz_data.split("\n") @@ -794,7 +795,7 @@ def get_nws_marine(zone, days=3): day_blocks.append(current_block.strip()) # Only keep up to pzDays blocks - for block in day_blocks[:days]: + for block in day_blocks[:my_settings.coastalForecastDays]: marine_pz_report += block + "\n" # remove last newline @@ -808,13 +809,13 @@ def get_nws_marine(zone, days=3): # abbreviate the report marine_pz_report = abbreviate_noaa(marine_pz_report) if marine_pz_report == "": - return NO_DATA_NOGPS + return my_settings.NO_DATA_NOGPS return marine_pz_report def checkUSGSEarthQuake(lat=0, lon=0): if lat == 0 and lon == 0: - lat = latitudeValue - lon = longitudeValue + lat = my_settings.latitudeValue + lon = my_settings.longitudeValue radius = 100 # km magnitude = 1.5 history = 7 # days @@ -824,20 +825,20 @@ def checkUSGSEarthQuake(lat=0, lon=0): quake_count = 0 # fetch the earthquake data from USGS try: - quake_data = requests.get(USGSquake_url, timeout=urlTimeoutSeconds) + quake_data = requests.get(USGSquake_url, timeout=my_settings.urlTimeoutSeconds) if not quake_data.ok: logger.warning("Location:Error fetching earthquake data from USGS") - return NO_ALERTS + return my_settings.NO_ALERTS if not quake_data.text.strip(): - return NO_ALERTS + return my_settings.NO_ALERTS try: quake_xml = xml.dom.minidom.parseString(quake_data.text) except Exception as e: logger.warning(f"Location: USGS earthquake API returned invalid XML: {e}") - return NO_ALERTS + return my_settings.NO_ALERTS except (requests.exceptions.RequestException): logger.warning("Location:Error fetching earthquake data from USGS") - return NO_ALERTS + return my_settings.NO_ALERTS quake_xml = xml.dom.minidom.parseString(quake_data.text) quake_count = len(quake_xml.getElementsByTagName("event")) @@ -853,7 +854,7 @@ def checkUSGSEarthQuake(lat=0, lon=0): description_text = event.getElementsByTagName("description")[0].getElementsByTagName("text")[0].childNodes[0].nodeValue largest_mag = round(largest_mag, 1) if quake_count == 0: - return NO_ALERTS + return my_settings.NO_ALERTS else: return f"{quake_count} 🫨quakes in last {history} days within {radius} km. Largest: {largest_mag}M\n{description_text}" @@ -867,7 +868,7 @@ def distance(lat=0,lon=0,nodeID=0, reset=False): r = 6371 # Radius of earth in kilometers # haversine formula if lat == 0 and lon == 0: - return NO_DATA_NOGPS + return my_settings.NO_DATA_NOGPS if nodeID == 0: return "No NodeID provided" @@ -899,7 +900,7 @@ def distance(lat=0,lon=0,nodeID=0, reset=False): c = 2 * math.asin(math.sqrt(a)) distance_km = c * r - if use_metric: + if my_settings.use_metric: msg += f"{distance_km:.2f} km" else: distance_miles = distance_km * 0.621371 @@ -917,7 +918,7 @@ def distance(lat=0,lon=0,nodeID=0, reset=False): time_diff = datetime.now() - last_point['time'] if time_diff.total_seconds() > 60: hours = time_diff.total_seconds() / 3600 - if use_metric: + if my_settings.use_metric: speed = distance_km / hours speed_str = f"{speed:.2f} km/h" else: @@ -941,7 +942,7 @@ def distance(lat=0,lon=0,nodeID=0, reset=False): total_distance_km += c * r # add the distance from last point to current point total_distance_km += distance_km - if use_metric: + if my_settings.use_metric: msg += f", Total: {total_distance_km:.2f} km" else: total_distance_miles = total_distance_km * 0.621371 @@ -974,7 +975,7 @@ def distance(lat=0,lon=0,nodeID=0, reset=False): area = area * (6378137 ** 2) / 2.0 area = abs(area) / 1e6 # convert to square kilometers - if use_metric: + if my_settings.use_metric: msg += f", Area: {area:.2f} sq.km (approx)" else: area_miles = area * 0.386102 @@ -1006,7 +1007,7 @@ def distance(lat=0,lon=0,nodeID=0, reset=False): def get_openskynetwork(lat=0, lon=0): # get the latest aircraft data from OpenSky Network in the area if lat == 0 and lon == 0: - return NO_ALERTS + return my_settings.NO_ALERTS # setup a bounding box of 50km around the lat/lon box_size = 0.45 # approx 50km # return limits for aircraft search @@ -1019,16 +1020,16 @@ def get_openskynetwork(lat=0, lon=0): # fetch the aircraft data from OpenSky Network opensky_url = f"https://opensky-network.org/api/states/all?lamin={lamin}&lomin={lomin}&lamax={lamax}&lomax={lomax}" try: - aircraft_data = requests.get(opensky_url, timeout=urlTimeoutSeconds) + aircraft_data = requests.get(opensky_url, timeout=my_settings.urlTimeoutSeconds) if not aircraft_data.ok: logger.warning("Location:Error fetching aircraft data from OpenSky Network") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA except (requests.exceptions.RequestException): logger.warning("Location:Error fetching aircraft data from OpenSky Network") - return ERROR_FETCHING_DATA + return my_settings.ERROR_FETCHING_DATA aircraft_json = aircraft_data.json() if 'states' not in aircraft_json or not aircraft_json['states']: - return NO_ALERTS + return my_settings.NO_ALERTS aircraft_list = aircraft_json['states'] aircraft_report = "" for aircraft in aircraft_list: @@ -1055,7 +1056,7 @@ def get_openskynetwork(lat=0, lon=0): if aircraft_report.endswith("\n"): aircraft_report = aircraft_report[:-1] aircraft_report = abbreviate_noaa(aircraft_report) - return aircraft_report if aircraft_report else NO_ALERTS + return aircraft_report if aircraft_report else my_settings.NO_ALERTS def log_locationData_toMap(userID, location, message): """ diff --git a/modules/log.py b/modules/log.py index 3ac6932..a2d9a52 100644 --- a/modules/log.py +++ b/modules/log.py @@ -1,11 +1,11 @@ import logging from logging.handlers import TimedRotatingFileHandler -from modules.settings import * +import modules.settings as my_settings # if LOGGING_LEVEL is not set in settings.py, default to DEBUG -if not LOGGING_LEVEL: - LOGGING_LEVEL = "DEBUG" +if not my_settings.LOGGING_LEVEL: + my_settings.LOGGING_LEVEL = "DEBUG" -LOGGING_LEVEL = getattr(logging, LOGGING_LEVEL) +LOGGING_LEVEL = getattr(logging, my_settings.LOGGING_LEVEL) class CustomFormatter(logging.Formatter): grey = '\x1b[38;21m' @@ -70,16 +70,16 @@ stdout_handler.setFormatter(CustomFormatter(logFormat)) # Add handlers to the logger logger.addHandler(stdout_handler) -if syslog_to_file: +if my_settings.syslog_to_file: # Create file handler for logging to a file - file_handler_sys = TimedRotatingFileHandler('logs/meshbot.log', when='midnight', backupCount=log_backup_count, encoding='utf-8') + file_handler_sys = TimedRotatingFileHandler('logs/meshbot.log', when='midnight', backupCount=my_settings.log_backup_count, encoding='utf-8') file_handler_sys.setLevel(LOGGING_LEVEL) # DEBUG used by default for system logs to disk file_handler_sys.setFormatter(plainFormatter(logFormat)) logger.addHandler(file_handler_sys) -if log_messages_to_file: +if my_settings.log_messages_to_file: # Create file handler for logging to a file - file_handler = TimedRotatingFileHandler('logs/messages.log', when='midnight', backupCount=log_backup_count, encoding='utf-8') + file_handler = TimedRotatingFileHandler('logs/messages.log', when='midnight', backupCount=my_settings.log_backup_count, encoding='utf-8') file_handler.setLevel(logging.INFO) # INFO used for messages to disk file_handler.setFormatter(logging.Formatter(msgLogFormat)) msgLogger.addHandler(file_handler) diff --git a/modules/qrz.py b/modules/qrz.py index b1afaa3..73fe5c9 100644 --- a/modules/qrz.py +++ b/modules/qrz.py @@ -3,7 +3,8 @@ import os import sqlite3 -from modules.log import * +from modules.log import logger +from modules.settings import qrz_db def initalize_qrz_database(): try: diff --git a/modules/radio.py b/modules/radio.py index 3768a15..4b1cb28 100644 --- a/modules/radio.py +++ b/modules/radio.py @@ -5,8 +5,25 @@ # requires vosk and sounddevice python modules. will auto download needed. more from https://alphacephei.com/vosk/models and unpack # 2024 Kelly Keeton K7MHI -from modules.log import * +from modules.log import logger import asyncio +from modules.settings import ( + radio_detection_enabled, + rigControlServerAddress, + signalDetectionThreshold, + signalHoldTime, + signalCooldown, + signalCycleLimit, + voxDetectionEnabled, + useLocalVoxModel, + localVoxModelPath, + voxLanguage, + voxInputDevice, + voxTrapList, + voxOnTrapList, + voxEnableCmd, + ERROR_FETCHING_DATA +) # verbose debug logging for trap words function debugVoxTmsg = False diff --git a/modules/rss.py b/modules/rss.py index 692f4ef..d5733f4 100644 --- a/modules/rss.py +++ b/modules/rss.py @@ -1,5 +1,6 @@ # rss feed module for meshing-around 2025 -from modules.log import * +from modules.log import logger +from modules.settings import rssFeedURL, rssFeedNames, rssMaxItems, rssTruncate, urlTimeoutSeconds, ERROR_FETCHING_DATA import urllib.request import xml.etree.ElementTree as ET import html diff --git a/modules/scheduler.py b/modules/scheduler.py index bfa7193..0461afe 100644 --- a/modules/scheduler.py +++ b/modules/scheduler.py @@ -3,6 +3,7 @@ import asyncio import schedule from modules.log import logger +from modules.settings import MOTD from modules.system import send_message async def setup_scheduler( diff --git a/modules/smtp.py b/modules/smtp.py index b469eb8..41b56f6 100644 --- a/modules/smtp.py +++ b/modules/smtp.py @@ -3,7 +3,12 @@ # https://avtech.com/articles/138/list-of-email-to-sms-addresses/ # 2024 Kelly Keeton K7MHI -from modules.log import * +from modules.log import logger +from modules.settings import ( + SMTP_SERVER, SMTP_PORT, SMTP_AUTH, SMTP_USERNAME, SMTP_PASSWORD, + FROM_EMAIL, EMAIL_SUBJECT, enableImap, IMAP_SERVER, IMAP_PORT, + IMAP_USERNAME, IMAP_PASSWORD, IMAP_FOLDER, sysopEmails, bbs_ban_list +) import pickle import time import smtplib diff --git a/modules/space.py b/modules/space.py index aa72b33..9be8402 100644 --- a/modules/space.py +++ b/modules/space.py @@ -7,7 +7,10 @@ import xml.dom.minidom from datetime import datetime import ephem # pip install pyephem from datetime import timezone -from modules.log import * +from modules.log import logger, getPrettyTime +from modules.settings import (latitudeValue, longitudeValue, zuluTime, + n2yoAPIKey, urlTimeoutSeconds, use_metric, + ERROR_FETCHING_DATA, NO_DATA_NOGPS, NO_ALERTS) import math trap_list_solarconditions = ("sun", "moon", "solar", "hfcond", "satpass", "howtall") diff --git a/modules/survey.py b/modules/survey.py index 4903bed..fec6e3c 100644 --- a/modules/survey.py +++ b/modules/survey.py @@ -13,7 +13,8 @@ import os # For file operations import csv from datetime import datetime from collections import Counter -from modules.log import * +from modules.log import logger +from modules.settings import surveyRecordLocation, surveyRecordID allowedSurveys = [] # List of allowed survey names diff --git a/modules/system.py b/modules/system.py index a07c0bf..d7cdd5a 100644 --- a/modules/system.py +++ b/modules/system.py @@ -12,7 +12,8 @@ import base64 import contextlib # for suppressing output on watchdog import io # for suppressing output on watchdog # homebrew 'modules' -from modules.log import * +from modules.settings import * +from modules.log import logger, getPrettyTime, CustomFormatter # Global Variables trap_list = ("cmd","cmd?","bannode",) # base commands diff --git a/modules/test_bot.py b/modules/test_bot.py index 1677871..27b173c 100644 --- a/modules/test_bot.py +++ b/modules/test_bot.py @@ -1,18 +1,22 @@ # test_bot.py # Unit tests for various modules in the meshing-around project -import unittest import os import sys + +# Add the parent directory to sys.path to allow module imports +parent_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) +sys.path.insert(0, parent_path) + +import unittest import importlib import pkgutil import warnings +from modules.log import logger +from modules.settings import latitudeValue, longitudeValue # Suppress ResourceWarning warnings for asyncio unclosed event here warnings.filterwarnings("ignore", category=ResourceWarning) -# Add the parent directory to sys.path to allow module imports -parent_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -sys.path.append(parent_path) modules_path = os.path.join(parent_path, 'modules') # Limits API calls during testing @@ -31,7 +35,7 @@ available_modules = [ try: print("\nImporting Core Modules:") - from modules.log import * + from modules.log import logger, getPrettyTime print(" ✔ Imported 'log'") # Set location default lat = latitudeValue diff --git a/modules/wiki.py b/modules/wiki.py index d45cda3..3528958 100644 --- a/modules/wiki.py +++ b/modules/wiki.py @@ -1,6 +1,8 @@ # meshbot wiki module -from modules.log import * +from modules.log import logger +from modules.settings import (use_kiwix_server, kiwix_url, kiwix_library_name, + urlTimeoutSeconds, wiki_return_limit, ERROR_FETCHING_DATA) #import wikipedia # pip install wikipedia import requests import bs4 as bs diff --git a/modules/wx_meteo.py b/modules/wx_meteo.py index 401e6b7..defd037 100644 --- a/modules/wx_meteo.py +++ b/modules/wx_meteo.py @@ -3,7 +3,8 @@ import requests import json -from modules.log import * +from modules.log import logger +from modules.settings import ERROR_FETCHING_DATA def get_weather_data(api_url, params): response = requests.get(api_url, params=params) diff --git a/pong_bot.py b/pong_bot.py index a4eda26..a6b2722 100755 --- a/pong_bot.py +++ b/pong_bot.py @@ -12,7 +12,8 @@ import asyncio import time # for sleep, get some when you can :) from datetime import datetime import random -from modules.log import * +from modules.log import logger, CustomFormatter, msgLogger +import modules.settings as my_settings from modules.system import * # Global Variables diff --git a/script/addFav.py b/script/addFav.py index 3afdc4e..6d2f978 100644 --- a/script/addFav.py +++ b/script/addFav.py @@ -34,8 +34,10 @@ print("---------------------------------------------------------------") try: # set the path to import the modules and config.ini sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) - from modules.log import * - from modules.system import * + from modules.log import logger, getPrettyTime + from modules.system import handleFavoriteNode + from modules.settings import LOGGING_LEVEL + from modules.system import compileFavoriteList except Exception as e: print(f"Error importing modules run this program from the main repo directory 'python3 script/addFav.py'") print(f"if you forgot the rest of it.. git clone https://github.com/spudgunman/meshing-around") diff --git a/script/injectDM.py b/script/injectDM.py index dd7bd3d..f6df9df 100644 --- a/script/injectDM.py +++ b/script/injectDM.py @@ -14,8 +14,10 @@ print("---------------------------------------------------------------") try: # set the path to import the modules and config.ini sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) - from modules.log import * - from modules.bbstools import * + from modules.log import logger + from modules.bbstools import bbs_post_dm, bbs_dm, get_bbs_stats + from modules.settings import LOGGING_LEVEL, vpTracker, MOTD + logger.setLevel(LOGGING_LEVEL) except Exception as e: print(f"Error importing modules run this program from the main program directory 'python3 script/injectDM.py'") exit(1)