From d855a5aec8960c4dc2c30d08456e42f16b028d75 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Thu, 15 Feb 2024 14:05:57 -0600 Subject: [PATCH 01/37] Updated EC to use latest module. Added rich module for better looking logging --- VERSION | 2 +- apt-requirements | 2 + requirements.txt | 20 +++++----- scripts/install_venv.sh | 70 +++++++++++++++++++++++++++++++++++ src/api/weather/ecAlerts.py | 6 +-- src/api/weather/ecWeather.py | 62 +++++++++++++++++-------------- src/api/weather/wxForecast.py | 21 ++++++++--- src/boards/wxWeather.py | 2 +- src/data/scoreboard.py | 2 +- src/debug.py | 12 +++++- src/main.py | 22 +++++++---- src/nhl_api/game.py | 1 + src/utils.py | 4 +- 13 files changed, 165 insertions(+), 61 deletions(-) create mode 100755 scripts/install_venv.sh diff --git a/VERSION b/VERSION index bd8bf882..27f9cd32 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.7.0 +1.8.0 diff --git a/apt-requirements b/apt-requirements index 9382c032..2d4ebcee 100644 --- a/apt-requirements +++ b/apt-requirements @@ -15,6 +15,8 @@ package "python3-pillow" package "python3-numpy" package "python3-gpiozero" package "python3-cairosvg" +package "python3-lxml" +package "libopenblas0" package "libatlas3-base" package "libatlas-base-dev" package "libraqm-dev" diff --git a/requirements.txt b/requirements.txt index 8b78c785..2702714e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,22 +1,20 @@ -env-canada==0.0.35 -ephem==3.7.7.0 +env-canada +ephem fastjsonschema>=2.14.4 -geocoder==1.38.1 +geocoder>=1.38.1 gpiozero==1.6.2 -httpx==0.20.0 nhl-api-py noaa-sdk>=0.1.18 -printtools==1.2 -PyInstaller==3.6 pyowm>=3.0.0 python-tsl2591==0.2.0 -questionary==1.9.0 -regex==2020.11.13 -requests==2.22.0 +regex>=2020.4.4 RPi.GPIO==0.7.0 APScheduler==3.10.4 lastversion>=1.1.6 -nameparser==1.0.6 -pillow +nameparser>=1.0.6 +pillow>=9.5.0 dbus-python iso6709 +cairosvg +tzlocal +rich diff --git a/scripts/install_venv.sh b/scripts/install_venv.sh new file mode 100755 index 00000000..59b13ca5 --- /dev/null +++ b/scripts/install_venv.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# Make script work regardless of where it is run from +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +cd "${DIR}/.." || exit + +tput bold; echo "$(tput setaf 2)Installing required OS dependencies. This may take some time (10-20 minutes-ish)...$(tput setaf 9)" ; tput sgr0 + +#Install all apt requirements using aptfile +sudo scripts/aptfile apt-requirements + +tput bold; echo "$(tput setaf 2)Creating python virtual environment...$(tput setaf 9)" ; tput sgr0 + +#Install all apt requirements using aptfile +#sudo scripts/aptfile apt-requirements + +# Update pip3 to latest version +python3 -m pip install --upgrade pip --break-system-packages + +# Install virtual enviroment, required for upcoming bookworm release +# Use already installed site-packages that were installed as part o fthe apt OS dependencies +python3 -m venv $HOME/nhlsb-venv --system-site-packages + +# Activate the direnv to allow for automatic activate and deactivate of venv +tput bold; echo "$(tput setaf 2)Activating direnv for python venv...$(tput setaf 9)" ; tput sgr0 + +echo "export VIRTUAL_ENV=~/nhlsb-venv" >> .envrc +echo "layout python" >> .envrc +direnv allow . + +echo "$(tput setaf 6)Activating python virtual environment...$(tput setaf 9)" + +source $HOME/nhlsb-venv/bin/activate + +echo "$(tput setaf 6)Updating pip in virtual environment...$(tput setaf 9)" +# Update pip in the virtual enviroment +python3 -m pip install --upgrade pip +#Install all pip3 requirements using the requirements.txt file +#This will install into the virtual environment + +tput bold; echo "$(tput setaf 2)Installing scoreboard python requirements in virtual environment...$(tput setaf 9)" ; tput sgr0 +pip3 install -r requirements.txt + +# Pull submodule and ignore changes from script +git submodule update --init --recursive +git config submodule.matrix.ignore all + +tput bold; echo "$(tput setaf 4)Running rgbmatrix installation...$(tput setaf 9)" ; tput sgr0 + +# No longer needed for newer version of the rgb matric repo as of Dec 2021 +# Recompile the cpp files to build library with newest cython. See https://github.com/hzeller/rpi-rgb-led-matrix/issues/1298 + +cd submodules/matrix/ || exit + +# python3 -m pip install --no-cache-dir cython +# python3 -m cython -2 --cplus *.pyx + +# cd ../../ || exit + +make build-python PYTHON="$(command -v python3)" +make install-python PYTHON="$(command -v python3)" + +cd ../../ || exit + +git reset --hard +git fetch origin --prune +git pull + +tput bold; echo "$(tput setaf 6)If you didn't see any errors above, everything should be installed!"; tput sgr0 +echo "$(tput bold)$(tput smso)$(tput setaf 2)Installation complete!$(tput sgr0) Play around with the examples in nhl-led-scoreboard/submodules/matrix/bindings/python/samples to make sure your matrix is working." \ No newline at end of file diff --git a/src/api/weather/ecAlerts.py b/src/api/weather/ecAlerts.py index 9b0ed093..abd5c2dc 100644 --- a/src/api/weather/ecAlerts.py +++ b/src/api/weather/ecAlerts.py @@ -1,8 +1,8 @@ -from env_canada import ECData +from env_canada import ECWeather import debug import datetime from time import sleep - +import asyncio class ecWxAlerts(object): def __init__(self, data, scheduler,sleepEvent): @@ -31,7 +31,7 @@ def getAlerts(self): debug.info("Checking for EC weather alerts") #ecData = ECData(coordinates=(self.data.latlng)) - self.data.ecData.update() + asyncio.run(self.data.ecData.update()) curr_alerts = self.data.ecData.alerts self.network_issues = False diff --git a/src/api/weather/ecWeather.py b/src/api/weather/ecWeather.py index aa71b66a..c3e60976 100644 --- a/src/api/weather/ecWeather.py +++ b/src/api/weather/ecWeather.py @@ -1,6 +1,7 @@ -from env_canada import ECData +from env_canada import ECWeather import debug import datetime +import asyncio from time import sleep from api.weather.wx_utils import cadhumidex, wind_chill, get_csv, degrees_to_direction, temp_f, wind_mph @@ -18,6 +19,11 @@ def __init__(self, data, scheduler): #scheduler.add_job(self.CheckForUpdate, 'cron', minute='*/5') #Get initial obs + # Make sure the weather units have a default if user makes a mistake in the config + if self.data.config.weather_units.lower() not in ("metric", "imperial"): + debug.info("Weather units not set correctly, defaulting to imperial") + self.data.config.weather_units="imperial" + self.getWeather() @@ -25,11 +31,13 @@ def getWeather(self): #while True: try: - self.data.ecData.update() + asyncio.run(self.data.ecData.update()) except Exception as e: debug.error("Unable to get EC current observations. Error {}".format(e)) curr_cond = self.data.ecData.conditions + + if len(curr_cond) == 0: debug.error("Unable to get EC current observations") self.data.wx_updated = False @@ -64,7 +72,7 @@ def getWeather(self): self.data.wx_updated = False try: - curr_humidity = curr_cond.get("humidity").get("value",{}) + curr_humidity = str(curr_cond.get("humidity").get("value",{})) except: curr_humidity = None self.data.wx_updated = False @@ -73,30 +81,8 @@ def getWeather(self): curr_humidity = "0" wx_humidity = "N/A" else: - wx_humidity = curr_humidity + "%" - - - - if curr_temp != None: - curr_temp = float(curr_cond["temperature"]["value"]) - check_windchill = 10.0 - if self.data.config.weather_units == "imperial": - curr_temp = temp_f(curr_temp) - check_windchill = 50.0 + wx_humidity = curr_humidity + "%" - - if curr_temp < check_windchill: - windchill = round(wind_chill(float(curr_cond["temperature"]["value"]),float(curr_cond["wind_speed"]["value"]),self.data.wx_units[1]),1) - wx_app_temp = str(windchill) + self.data.wx_units[0] - else: - humidex = round(cadhumidex(curr_temp,int(curr_humidity)),1) - wx_app_temp = str(humidex) + self.data.wx_units[0] - wx_temp = str(round(curr_temp,1)) + self.data.wx_units[0] - - else: - wx_temp = "N/A" - wx_app_temp = "N/A" - try: icon_code = curr_cond.get("icon_code").get("value","90") except: @@ -139,8 +125,6 @@ def getWeather(self): else: wx_dewpoint = str(curr_dewpoint) + self.data.wx_units[0] - self.data.wx_current = [wx_timestamp,wx_icon,wx_summary,wx_temp ,wx_app_temp ,wx_humidity,wx_dewpoint] - try: wind_bearing = curr_cond.get("wind_bearing").get("value","0") except: @@ -185,6 +169,28 @@ def getWeather(self): except: wx_pressure = "N/A" + if curr_temp != None: + curr_temp = float(curr_cond["temperature"]["value"]) + check_windchill = 10.0 + if self.data.config.weather_units == "imperial": + curr_temp = temp_f(curr_temp) + check_windchill = 50.0 + + + if curr_temp < check_windchill: + windchill = round(wind_chill(curr_temp,curr_windspeed,self.data.wx_units[1]),1) + wx_app_temp = str(windchill) + self.data.wx_units[0] + else: + humidex = round(cadhumidex(curr_temp,int(curr_humidity)),1) + wx_app_temp = str(humidex) + self.data.wx_units[0] + wx_temp = str(round(curr_temp,1)) + self.data.wx_units[0] + + else: + wx_temp = "N/A" + wx_app_temp = "N/A" + + self.data.wx_current = [wx_timestamp,wx_icon,wx_summary,wx_temp ,wx_app_temp ,wx_humidity,wx_dewpoint] + try: for row in range(len(self.icons)): if self.icons[row]["Description"].lower() == curr_cond.get("tendency").get("value","N/A"): diff --git a/src/api/weather/wxForecast.py b/src/api/weather/wxForecast.py index 10259298..2a2a99c7 100644 --- a/src/api/weather/wxForecast.py +++ b/src/api/weather/wxForecast.py @@ -1,9 +1,10 @@ from pyowm.owm import OWM -from env_canada import ECData +from env_canada import ECWeather import debug from datetime import datetime,timedelta from time import sleep from api.weather.wx_utils import cadhumidex, wind_chill, get_csv, degrees_to_direction, temp_f, wind_mph +import asyncio class wxForecast(object): def __init__(self, data, scheduler): @@ -38,6 +39,10 @@ def __init__(self, data, scheduler): #Set up units [temp, wind speed,precip, storm distance] #Use these eventhough some are included in data feed + if self.data.config.weather_units.lower() not in ("metric", "imperial"): + debug.info("Weather units not set correctly, defaulting to imperial") + self.data.config.weather_units="imperial" + if self.data.config.weather_units == "metric": self.data.wx_units = ["C","kph","mm","miles","hPa","ca"] else: @@ -63,7 +68,7 @@ def getForecast(self): if self.data.config.weather_data_feed.lower() == "ec": debug.info("Refreshing EC daily weather forecast") try: - self.data.ecData.update() + asyncio.run(self.data.ecData.update()) except Exception as e: debug.error("Unable to update EC forecast. Error: {}".format(e)) @@ -95,10 +100,10 @@ def getForecast(self): #print(day_forecast) summary = day_forecast['text_summary'] icon_code = day_forecast['icon_code'] - temp_high = day_forecast['temperature'] + self.data.wx_units[0] + temp_high = str(day_forecast['temperature']) + self.data.wx_units[0] # Get the nextdate_name + " night" night_forecast = next((sub for sub in forecasts if sub['period'] == nextdate_name + " night"), None) - temp_low = night_forecast['temperature'] + self.data.wx_units[0] + temp_low = str(night_forecast['temperature']) + self.data.wx_units[0] break if icon_code == None: @@ -132,7 +137,7 @@ def getForecast(self): #lon = self.data.latlng[1] one_call = None try: - one_call = self.owm_manager.one_call(lat=self.data.latlng[0],lon=self.data.latlng[1]) + one_call = self.owm_manager.one_call(lat=self.data.latlng[0],lon=self.data.latlng[1],exclude='current,minutely,hourly,alerts') except Exception as e: debug.error("Unable to get OWM data error:{0}".format(e)) self.data.forecast_updated = False @@ -169,6 +174,9 @@ def getForecast(self): elif icon_code in range(600,699): # Rain Class owm_icon = 600 + elif icon_code in range(700,741): + # Rain Class + owm_icon = 741 elif icon_code in range(800,805): # Rain Class owm_icon = 801 @@ -206,4 +214,5 @@ def getForecast(self): debug.info(self.data.wx_forecast) nextrun = self.scheduler.get_job('forecast').next_run_time - debug.info("Weather forecast next update @ {}".format(nextrun.strftime("%H:%M"))) + if nextrun == True: + debug.info("Weather forecast next update @ {}".format(nextrun.strftime("%H:%M"))) diff --git a/src/boards/wxWeather.py b/src/boards/wxWeather.py index 3615b8cb..d90f9735 100644 --- a/src/boards/wxWeather.py +++ b/src/boards/wxWeather.py @@ -65,7 +65,7 @@ def __init__(self, data, matrix,sleepEvent): display_wx += display_sleep else: if self.data.config.weather_enabled: - debug.error("Weather feed has not updated yet....") + debug.error("Weather feed (current conditions) has not updated yet....") else: debug.error("Weather board not enabled in config.json. Is enabled set to True?") diff --git a/src/data/scoreboard.py b/src/data/scoreboard.py index fe824660..1e9c6b24 100755 --- a/src/data/scoreboard.py +++ b/src/data/scoreboard.py @@ -237,7 +237,7 @@ def __init__(self, game_details, data): home_team_name = home_team["placeName"]["default"] home_abbrev = data.teams_info[home_team_id].details.abbrev - if game_details["awayTeam"].get("score"): + if game_details["homeTeam"].get("score") or game_details["awayTeam"].get("score"): self.away_team = TeamScore(away_team_id, away_abbrev, away_team_name, game_details["awayTeam"]["score"]) self.home_team = TeamScore(home_team_id, home_abbrev, home_team_name, game_details["homeTeam"]["score"]) else: diff --git a/src/debug.py b/src/debug.py index 57126e4e..052fcc40 100644 --- a/src/debug.py +++ b/src/debug.py @@ -3,6 +3,7 @@ import time import sys import logging +from rich.logging import RichHandler debug_enabled = False @@ -35,7 +36,7 @@ def set_debug_status(config,logcolor=False,loglevel='INFO'): if colorAvail: coloredlogs.install(level='DEBUG',fmt='%(asctime)s %(name)s %(levelname)s %(message)s',stream=sys.stdout) else: - logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=logging.DEBUG, datefmt='%y-%m-%d %H:%M:%S') + logging.basicConfig(format='%(message)s', level=logging.DEBUG, datefmt='%y-%m-%d %H:%M:%S',handlers=[RichHandler(omit_repeated_times=False,tracebacks_show_locals=True,rich_tracebacks=True)]) else: if colorAvail: @@ -44,7 +45,8 @@ def set_debug_status(config,logcolor=False,loglevel='INFO'): handler = logging.StreamHandler(sys.stdout) formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S') handler.setFormatter(formatter) - logger.addHandler(handler) + #logger.addHandler(handler) + logger.addHandler(RichHandler(show_path=False,omit_repeated_times=False,tracebacks_show_locals=True,rich_tracebacks=True)) logger.setLevel(loglevel) @@ -57,6 +59,12 @@ def log(text): #__debugprint("DEBUG ({}): {}".format(__timestamp(), text)) logger.debug(text) +def critical(text): + logger.critical(text,stack_info=True) + +def exception(text,e): + logger.exception(text,exc_info=e) + def warning(text): #__debugprint("WARNING ({}): {}".format(__timestamp(), text)) logger.warn(text) diff --git a/src/main.py b/src/main.py index e4d0d2c5..d363c6ff 100644 --- a/src/main.py +++ b/src/main.py @@ -4,7 +4,7 @@ from data.scoreboard_config import ScoreboardConfig from renderer.main import MainRenderer from rgbmatrix import RGBMatrix, RGBMatrixOptions -from utils import args, led_matrix_options, stop_splash_service +from utils import args, led_matrix_options, stop_splash_service, scheduler_event_listener from data.data import Data import threading from sbio.dimmer import Dimmer @@ -17,17 +17,23 @@ from api.weather.ecAlerts import ecWxAlerts from api.weather.nwsAlerts import nwsWxAlerts from api.weather.wxForecast import wxForecast -from env_canada import ECData +import asyncio +from env_canada import ECWeather from renderer.matrix import Matrix from update_checker import UpdateChecker +import tzlocal +from apscheduler.events import EVENT_ALL, EVENT_JOB_ERROR, EVENT_JOB_MISSED from apscheduler.schedulers.background import BackgroundScheduler from renderer.loading_screen import Loading import debug import os +# If you want real fancy stack trace dumps, uncomment these two lines +#from rich.traceback import install +#install(show_locals=True) SCRIPT_NAME = "NHL-LED-SCOREBOARD" -SCRIPT_VERSION = "1.7.0" +SCRIPT_VERSION = "1.8.0" def run(): @@ -85,7 +91,8 @@ def run(): # Start task scheduler, used for UpdateChecker and screensaver, forecast, dimmer and weather - scheduler = BackgroundScheduler() + scheduler = BackgroundScheduler(timezone=str(tzlocal.get_localzone()), job_defaults={'misfire_grace_time': None}) + scheduler.add_listener(scheduler_event_listener, EVENT_JOB_MISSED | EVENT_JOB_ERROR) scheduler.start() # Any tasks that are scheduled go below this line @@ -96,11 +103,12 @@ def run(): #Create EC data feed handler if data.config.weather_enabled or data.config.wxalert_show_alerts: if data.config.weather_data_feed.lower() == "ec" or data.config.wxalert_alert_feed.lower() == "ec": + data.ecData = ECWeather(coordinates=(tuple(data.latlng))) + try: - data.ecData = ECData(coordinates=(data.latlng)) + asyncio.run(data.ecData.update()) except Exception as e: - debug.error("Unable to connect to EC, try running again in a few minutes") - sys.exit(0) + debug.error("Unable to connect to EC .. will try on next refresh : {}".format(e)) if data.config.weather_enabled: if data.config.weather_data_feed.lower() == "ec": diff --git a/src/nhl_api/game.py b/src/nhl_api/game.py index 48f12a0a..fa1a03f8 100644 --- a/src/nhl_api/game.py +++ b/src/nhl_api/game.py @@ -32,6 +32,7 @@ def __repr__(self): def overview(game_id): + client = NHLClient(verbose=False) game_details = {} #with client as client: diff --git a/src/utils.py b/src/utils.py index 4d38898c..c4abc57b 100644 --- a/src/utils.py +++ b/src/utils.py @@ -23,7 +23,9 @@ def stop_splash_service(): except Exception as ex: nosvc = ex - +def scheduler_event_listener(event): + debug.error(f'Job {event.job_id} raised {event.exception.__class__.__name__}') + def get_lat_lng(location): #Check to see if a location.json is in the config folder From b2998ce8d92faa4c0b43804eb8677d959958de54 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Thu, 15 Feb 2024 19:15:40 -0600 Subject: [PATCH 02/37] Updated OWM to use One Call 2.5 API. Added diskcache to store location and OWM curr obs --- requirements.txt | 1 + scripts/install_venv.sh | 2 +- src/api/weather/README.md | 1 + src/api/weather/ecWeather.py | 7 +--- src/api/weather/owmWeather.py | 69 ++++++++++++++++++++++++++--------- src/api/weather/wxForecast.py | 4 +- src/boards/wxForecast.py | 6 +++ src/boards/wxWeather.py | 5 +++ src/main.py | 3 +- src/utils.py | 63 +++++++++++++------------------- 10 files changed, 97 insertions(+), 64 deletions(-) diff --git a/requirements.txt b/requirements.txt index 2702714e..e40b8fc3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,3 +18,4 @@ iso6709 cairosvg tzlocal rich +diskcache \ No newline at end of file diff --git a/scripts/install_venv.sh b/scripts/install_venv.sh index 59b13ca5..4bfd652b 100755 --- a/scripts/install_venv.sh +++ b/scripts/install_venv.sh @@ -14,7 +14,7 @@ tput bold; echo "$(tput setaf 2)Creating python virtual environment...$(tput set #Install all apt requirements using aptfile #sudo scripts/aptfile apt-requirements -# Update pip3 to latest version +# Update system pip3 to latest version python3 -m pip install --upgrade pip --break-system-packages # Install virtual enviroment, required for upcoming bookworm release diff --git a/src/api/weather/README.md b/src/api/weather/README.md index 6f88a892..c1c94c53 100644 --- a/src/api/weather/README.md +++ b/src/api/weather/README.md @@ -34,6 +34,7 @@ The name of the board that can be added to the different states is : **weather** | scroll\_alert | Bool | true,false | Scroll the text of the alert on the initial alert page. If you select false, a static page will be displayed that is the same as the 4th page on the weather board | | alert\_duration | INT | 5 | How long to show alert board (in seconds). This is for the non-scrolling alert board. | | show\_on\_clock | Bool | true,false | Add the last observed temperature and humidity to the bottom of the clock board | +| view | String | full, summary | Weather board full (3 page) or summary view (1 page) | > ***NOTE*** When you register for an OWM API key, it can take up to a day before it is activated. Select the Current Weather Data one as that's what the pyowm library uses. Also, you are limited on the number of API calls you can make, so choose your update time accordingly. 5 minutes makes the most sense as the lowest amonunt of time you can do API calls. diff --git a/src/api/weather/ecWeather.py b/src/api/weather/ecWeather.py index c3e60976..4e90d95b 100644 --- a/src/api/weather/ecWeather.py +++ b/src/api/weather/ecWeather.py @@ -37,13 +37,11 @@ def getWeather(self): curr_cond = self.data.ecData.conditions - if len(curr_cond) == 0: - debug.error("Unable to get EC current observations") + debug.error("Unable to get EC current observations. Check https://dd.weather.gc.ca/citypage_weather/xml/ to see if current conditions are populated.") self.data.wx_updated = False else: - self.data.wx_updated = True - + self.data.wx_updated = True #if self.data.wx_updated: #Set up units [temp, wind speed,precip, storm distance] @@ -54,7 +52,6 @@ def getWeather(self): self.data.wx_units = ["F","mph","in","miles","MB","us"] - #Uncomment next line if you want to see what is being returned back from EC #debug.info(curr_cond) diff --git a/src/api/weather/owmWeather.py b/src/api/weather/owmWeather.py index 083ccce4..f0ce3db3 100644 --- a/src/api/weather/owmWeather.py +++ b/src/api/weather/owmWeather.py @@ -1,8 +1,10 @@ from pyowm.owm import OWM import debug import geocoder -import datetime +import json +from datetime import datetime, time from time import sleep +from utils import sb_cache from api.weather.wx_utils import wind_chill, get_csv, degrees_to_direction, dew_point, wind_kmph, usaheatindex, temp_f class owmWxWorker(object): @@ -21,7 +23,10 @@ def __init__(self, data, scheduler): scheduler.add_job(self.getWeather, 'interval', minutes=self.weather_frequency,jitter=60,id='owmWeather') #Check every 5 mins for testing only #scheduler.add_job(self.CheckForUpdate, 'cron', minute='*/5') - + if self.data.config.weather_units.lower() not in ("metric", "imperial"): + debug.info("Weather units not set correctly, defaulting to imperial") + self.data.config.weather_units ="imperial" + #Get initial obs self.getWeather() @@ -40,11 +45,31 @@ def getWeather(self): #lat = 32.653 #lon = -83.7596 try: - debug.info("Refreshing OWM current observations weather") - - obs = self.owm_manager.weather_at_coords(lat,lon) - self.network_issues = False - self.data.wx_updated = True + # Check cache first + wx_cache,expiration_time = sb_cache.get("weather",expire_time=True) + if wx_cache is None: + debug.info("Refreshing OWM current observations weather") + #obs = self.owm_manager.weather_at_coords(lat,lon) + obs = self.owm_manager.one_call(lat=lat,lon=lon,exclude='daily,minutely,hourly,alerts',units=self.data.config.weather_units) + self.network_issues = False + self.data.wx_updated = True + + #wx = obs.weather.to_dict() + wx = obs.current.to_dict() + + # Store in cache and expire after weather_frequency minutes less 1 second + expiretime=(self.weather_frequency*60)-1 + sb_cache.set("weather",json.dumps(wx,indent=4),expire=expiretime) + else: + # Get the time that the cache was created + current_time = datetime.now().timestamp() + # Calculate the remaining time in seconds + remaining_time_seconds = int(max(0, int(expiration_time) - current_time)) + + debug.info("Loading weather from cache...cache expires in {} seconds".format(remaining_time_seconds)) + wx = json.loads(wx_cache) + self.network_issues = False + self.data.wx_updated = True #except PyOWMError as e: # #raise ValueError(e) @@ -59,12 +84,11 @@ def getWeather(self): pass if not self.network_issues: - wx = obs.weather.to_dict() if self.time_format == "%H:%M": - wx_timestamp = datetime.datetime.now().strftime("%m/%d %H:%M") + wx_timestamp = datetime.now().strftime("%m/%d %H:%M") else: - wx_timestamp = datetime.datetime.now().strftime("%m/%d %I:%M %p") + wx_timestamp = datetime.now().strftime("%m/%d %I:%M %p") owm_wxcode = int(wx.get("weather_code")) @@ -80,6 +104,9 @@ def getWeather(self): elif owm_wxcode in range(600,699): # Rain Class owm_icon = 600 + elif owm_wxcode in range(700,799): + # Rain Class + owm_icon = 741 elif owm_wxcode in range(800,805): # Rain Class owm_icon = 801 @@ -99,10 +126,12 @@ def getWeather(self): wx_summary = wx.get("detailed_status") # Get wind information. - if self.data.config.weather_units != "metric": - wx_wind = obs.weather.wind(unit='miles_hour') - else: - wx_wind = obs.weather.wind() + # if self.data.config.weather_units != "metric": + # wx_wind = obs.weather.wind(unit='miles_hour') + # else: + # wx_wind = obs.weather.wind() + + wx_wind = wx.get("wind") owm_windspeed = wx_wind['speed'] if 'gust' in wx_wind: @@ -124,13 +153,17 @@ def getWeather(self): wx_windspeed = str(round(owm_windspeed,1)) + self.data.wx_units[1] # Get temperature and apparent temperature based on weather units + + owm_temp = wx.get("temperature")['temp'] + owm_app_temp = wx.get("temperature")['feels_like'] + if self.data.config.weather_units == "metric": - owm_temp = obs.weather.temperature('celsius')['temp'] - owm_app_temp = obs.weather.temperature('celsius')['feels_like'] + #owm_temp = obs.weather.temperature('celsius')['temp'] + #owm_app_temp = obs.weather.temperature('celsius')['feels_like'] check_windchill = 10.0 else: - owm_temp = obs.weather.temperature('fahrenheit')['temp'] - owm_app_temp = obs.weather.temperature('fahrenheit')['feels_like'] + #owm_temp = obs.weather.temperature('fahrenheit')['temp'] + #owm_app_temp = obs.weather.temperature('fahrenheit')['feels_like'] check_windchill = 50.0 if owm_app_temp == None: diff --git a/src/api/weather/wxForecast.py b/src/api/weather/wxForecast.py index 2a2a99c7..29b00e8e 100644 --- a/src/api/weather/wxForecast.py +++ b/src/api/weather/wxForecast.py @@ -137,7 +137,9 @@ def getForecast(self): #lon = self.data.latlng[1] one_call = None try: - one_call = self.owm_manager.one_call(lat=self.data.latlng[0],lon=self.data.latlng[1],exclude='current,minutely,hourly,alerts') + # The following line currently breaks getting the forecasts. + #one_call = self.owm_manager.one_call(lat=self.data.latlng[0],lon=self.data.latlng[1],exclude='current,minutely,hourly,alerts') + one_call = self.owm_manager.one_call(lat=self.data.latlng[0],lon=self.data.latlng[1]) except Exception as e: debug.error("Unable to get OWM data error:{0}".format(e)) self.data.forecast_updated = False diff --git a/src/boards/wxForecast.py b/src/boards/wxForecast.py index 3b9c1551..2a9f789a 100644 --- a/src/boards/wxForecast.py +++ b/src/boards/wxForecast.py @@ -1,5 +1,7 @@ from PIL import Image, ImageFont, ImageDraw, ImageSequence + from rgbmatrix import graphics + from time import sleep from utils import center_text,get_file import debug @@ -56,6 +58,10 @@ def __init__(self, data, matrix,sleepEvent): def WxDrawForecast(self,display_loop,forecast_day=1): + if not self.data.config.weather_forecast_enabled or not self.data.config.weather_enabled: + debug.info("Weather forecast not enabled, skipping display of Forecast board") + return + x=0 pos = self.matrix.width # If the summary is to scroll, change size of display loop diff --git a/src/boards/wxWeather.py b/src/boards/wxWeather.py index d90f9735..c754a906 100644 --- a/src/boards/wxWeather.py +++ b/src/boards/wxWeather.py @@ -16,6 +16,11 @@ def __init__(self, data, matrix,sleepEvent): self.wxfont = data.config.layout.wxfont self.view = data.config.weather_view + + # Default to full if invalid values set in config + if self.view.lower() not in ("full", "summary"): + debug.info("Valid value for view not found, setting to full") + self.view = "full" self.matrix = matrix diff --git a/src/main.py b/src/main.py index d363c6ff..277b00f8 100644 --- a/src/main.py +++ b/src/main.py @@ -4,7 +4,7 @@ from data.scoreboard_config import ScoreboardConfig from renderer.main import MainRenderer from rgbmatrix import RGBMatrix, RGBMatrixOptions -from utils import args, led_matrix_options, stop_splash_service, scheduler_event_listener +from utils import args, led_matrix_options, stop_splash_service, scheduler_event_listener, sb_cache from data.data import Data import threading from sbio.dimmer import Dimmer @@ -166,4 +166,5 @@ def run(): except KeyboardInterrupt: print("Exiting NHL-LED-SCOREBOARD\n") + sb_cache.close() sys.exit(0) diff --git a/src/utils.py b/src/utils.py index c4abc57b..ca6aaff2 100644 --- a/src/utils.py +++ b/src/utils.py @@ -2,6 +2,7 @@ import collections import argparse import os +import diskcache as dc import debug from datetime import datetime, timezone, time import regex @@ -14,6 +15,9 @@ uid = int(os.stat("./VERSION").st_uid) gid = int(os.stat("./VERSION").st_uid) +# For caching weather and location data +sb_cache = dc.Cache("/tmp/sb_cache") + def stop_splash_service(): sysbus = dbus.SystemBus() systemd1 = sysbus.get_object('org.freedesktop.systemd1', '/org/freedesktop/systemd1') @@ -35,35 +39,26 @@ def get_lat_lng(location): latlng = [] j = {} - path = get_file("config/location.json") - if os.path.isfile(path): - try: - j = json.load(open(path)) - msg = "json loaded OK" - #Get the city, country and latlng from the loaded json - latlng = [j["lat"],j["lng"]] - #Check the age of the file, if it's older than 7 days, reload it. - t = os.stat(path)[8] - filetime = datetime.fromtimestamp(t) - today - if filetime.days <= -7: - reload = True - - if reload: - message = "location loaded from cache has expired, reloading...." - else: - if len(location) > 0: - message = "location loaded from cache (saved {} days ago): ".format(filetime.days) + location + " " + str(latlng) - else: - message = "location loaded from cache (saved {} days ago): ".format(filetime.days) + j["city"] + ", "+ j["country"] + " " + str(latlng) - - except json.decoder.JSONDecodeError as e: - msg = "Unable to load json: {0}".format(e) - j = {} - reload = True + + j_cache, expiration_time = sb_cache.get("location",expire_time=True) + if j_cache is not None: + j = json.loads(j_cache) + # Get the time that the cache was created + current_time = datetime.now().timestamp() + # Calculate the remaining time in seconds + remaining_time_seconds = max(0, current_time - int(expiration_time)) + remaining_days = int(remaining_time_seconds/86400) + + latlng = [j["lat"],j["lng"]] + if len(location) > 0: + message = "location loaded from cache (saved {} days ago): ".format(remaining_days) + location + " " + str(latlng) + else: + message = "location loaded from cache (saved {} days ago): ".format(remaining_days) + j["city"] + ", "+ j["country"] + " " + str(latlng) else: - msg="Unable to open file {}".format(path) + # Cache has expired reload = True - + message = "location loaded from cache has expired, reloading...." + if reload: if len(location) > 0: @@ -103,17 +98,9 @@ def get_lat_lng(location): if g.ok: #Dump the location to a file savefile = json.dumps(g.json, sort_keys=False, indent=4) - try: - with open(path,'w') as f: - try: - f.write(savefile) - #Change the ownership of the location.json file - os.chown(path, uid, gid) - except Exception as e: - debug.error("Could not write {0}. Error Message: {1}".format(path,e)) - except Exception as e: - debug.error("Could not open {0} unable to save location.json. Error Message: {1}".format(path,e)) - + # Store in cache and expire after 7 days + sb_cache.set("location",savefile,expire=604800) + return latlng,message From 0c3d9d6b0d5eed3cf413b63ac0ad00d5d6e5c95e Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 16 Feb 2024 19:47:21 -0600 Subject: [PATCH 03/37] Update apt requirements to allow for virtual env creation --- apt-requirements | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apt-requirements b/apt-requirements index 2d4ebcee..4f3636bf 100644 --- a/apt-requirements +++ b/apt-requirements @@ -5,21 +5,20 @@ update # install some packages package "build-essential" -package "libdbus-glib-1-dev" -package "libgirepository1.0-dev" package "git" package "python3-setuptools" package "python3-pip" package "python3-dev" +package "python3-virtualenv" package "python3-pillow" package "python3-numpy" package "python3-gpiozero" package "python3-cairosvg" package "python3-lxml" package "libopenblas0" -package "libatlas3-base" package "libatlas-base-dev" package "libraqm-dev" +package "direnv" #For the issueUpload.sh package "jq" package "pastebinit" @@ -28,6 +27,9 @@ package "neofetch" package "zsh" #For dietpi users without dbus package "dbus" +package "libdbus-glib-1-dev" +package "libgirepository1.0-dev" +pacakge "libdbus-1-dev" # you can also execute arbitrary bash echo "🚨 ALL GOOD TO GO" From e87bb8d168b368232957bc6236d8374cc86a6b8b Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 16 Feb 2024 20:07:25 -0600 Subject: [PATCH 04/37] Add blacklist of sound module and also note of new python location to run commands --- scripts/install_venv.sh | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/scripts/install_venv.sh b/scripts/install_venv.sh index 4bfd652b..528cfdef 100755 --- a/scripts/install_venv.sh +++ b/scripts/install_venv.sh @@ -62,9 +62,33 @@ make install-python PYTHON="$(command -v python3)" cd ../../ || exit +# Blacklist the snd_bcm2835 sounds module +sudo tee /etc/modprobe.d/blacklist-rgbmatrix.conf < Date: Fri, 16 Feb 2024 20:14:46 -0600 Subject: [PATCH 05/37] update boot to enforce isolcpus=3 --- scripts/install_venv.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install_venv.sh b/scripts/install_venv.sh index 528cfdef..4ee7d5b7 100755 --- a/scripts/install_venv.sh +++ b/scripts/install_venv.sh @@ -81,6 +81,8 @@ sudo modprobe -r snd_bcm2835 # Rebuild module dependacy sudo depmod -a +sudo sed -i 's/$/ isolcpus=3/' /boot/cmdline.txt + git reset --hard git fetch origin --prune git pull From 177bf1c4c118179601395832825325e72acb0787 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 16 Feb 2024 20:24:46 -0600 Subject: [PATCH 06/37] Update aptfile --- scripts/aptfile | 135 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 110 insertions(+), 25 deletions(-) diff --git a/scripts/aptfile b/scripts/aptfile index 01bb3b90..6e42f649 100755 --- a/scripts/aptfile +++ b/scripts/aptfile @@ -1,5 +1,6 @@ #!/usr/bin/env bash -set -eo pipefail; [[ $TRACE ]] && set -x && export TRACE=$TRACE +set -eo pipefail +[[ $TRACE ]] && set -x && export TRACE=$TRACE version() { local VERSION="dev-master" @@ -46,7 +47,8 @@ abs_dirname() { } expand_path() { - { cd "$(dirname "$1")" 2>/dev/null + { + cd "$(dirname "$1")" 2>/dev/null local dirname="$PWD" cd "$OLDPWD" echo "$dirname/$(basename "$1")" @@ -74,18 +76,18 @@ done for option in "${options[@]}"; do case "$option" in - "h" | "help" ) - help - exit 0 - ;; - "v" | "version" ) - version - exit 0 - ;; - * ) - usage >&2 - exit 1 - ;; + "h" | "help") + help + exit 0 + ;; + "v" | "version") + version + exit 0 + ;; + *) + usage >&2 + exit 1 + ;; esac done @@ -98,12 +100,12 @@ if [ "${#arguments[@]}" -eq 0 ]; then set -- "aptfile" "$@" fi -export APTFILE_COLOR_OFF="\033[0m" # unsets color to term fg color -export APTFILE_RED="\033[0;31m" # red -export APTFILE_GREEN="\033[0;32m" # green -export APTFILE_YELLOW="\033[0;33m" # yellow -export APTFILE_MAGENTA="\033[0;35m" # magenta -export APTFILE_CYAN="\033[0;36m" # cyan +export APTFILE_COLOR_OFF="\033[0m" # unsets color to term fg color +export APTFILE_RED="\033[0;31m" # red +export APTFILE_GREEN="\033[0;32m" # green +export APTFILE_YELLOW="\033[0;33m" # yellow +export APTFILE_MAGENTA="\033[0;35m" # magenta +export APTFILE_CYAN="\033[0;36m" # cyan logfile=$(basename "$0") TMP_APTFILE_LOGFILE=$(mktemp "/tmp/${logfile}.XXXXXX") || { @@ -127,7 +129,7 @@ log_info() { update() { [[ $TRACE ]] && set -x log_info "Running update" - apt-get update > "$TMP_APTFILE_LOGFILE" 2>&1 + apt-get update >"$TMP_APTFILE_LOGFILE" 2>&1 [[ $? -eq 0 ]] || log_fail "Failed to run update" } @@ -135,12 +137,54 @@ package() { [[ $TRACE ]] && set -x [[ -z $1 ]] && log_fail "Please specify a package to install" local pkg="$1" - dpkg --force-confnew -s "$pkg" > "$TMP_APTFILE_LOGFILE" 2>&1 && log_info "${APTFILE_CYAN}[OK]${APTFILE_COLOR_OFF} package $pkg" && return 0 - apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" -qq -y --force-yes install "$pkg" + dpkg --force-confnew -s "$pkg" >"$TMP_APTFILE_LOGFILE" 2>&1 && log_info "${APTFILE_CYAN}[OK]${APTFILE_COLOR_OFF} package $pkg" && return 0 + apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" -qq -y install "$pkg" [[ $? -eq 0 ]] || log_fail "${APTFILE_RED}[FAIL]${APTFILE_COLOR_OFF} package $pkg" log_info "${APTFILE_GREEN}[NEW]${APTFILE_COLOR_OFF} package $pkg" } +package_from_url() { + [[ $TRACE ]] && set -x + [[ -z $2 ]] && log_fail "Please specify a name and a download url to install the package from" + local name=$1 + local url=$2 + if type curl >/dev/null 2>&1; then + local dl_cmd="curl" + local dl_options="-so" + elif type wget >/dev/null 2>&1; then + local dl_cmd="wget" + local dl_options="-qO" + else + log_fail "Neither curl nor wget found. Unable to download $url" + fi + dpkg --force-confnew -s "$name" >"$TMP_APTFILE_LOGFILE" 2>&1 && log_info "${APTFILE_CYAN}[OK]${APTFILE_COLOR_OFF} package $name" && return 0 + tempdir=$(mktemp -d) + $dl_cmd $dl_options $tempdir/${name}.deb $url \ + && apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" -qq -y install "$tempdir/${name}.deb" + if [[ $? -ne 0 ]]; then + rm -r $tempdir + log_fail "${APTFILE_RED}[FAIL]${APTFILE_COLOR_OFF} package $name" + fi + rm -r $tempdir + log_info "${APTFILE_GREEN}[NEW]${APTFILE_COLOR_OFF} package $name" +} + +packagelist() { + [[ $TRACE ]] && set -x + [[ -z $1 ]] && log_fail "Please specify at least one package to install" + local input_packages=$@ + local install_packages=() + for pkg in $input_packages; do + dpkg --force-confnew -s "$pkg" >"$TMP_APTFILE_LOGFILE" 2>&1 && log_info "${APTFILE_CYAN}[OK]${APTFILE_COLOR_OFF} package $pkg" && continue + install_packages+=($pkg) + done + if [[ ${#install_packages[@]} -gt 0 ]]; then + apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" -qq -y install ${install_packages[@]} + [[ $? -eq 0 ]] || log_fail "${APTFILE_RED}[FAIL]${APTFILE_COLOR_OFF} packages ${install_packages[@]}" + log_info "${APTFILE_GREEN}[NEW]${APTFILE_COLOR_OFF} packages ${install_packages[@]}" + fi +} + ppa() { [[ $TRACE ]] && set -x [[ -z $1 ]] && log_fail "Please specify a repository to setup" @@ -158,7 +202,45 @@ repository() { if [[ -d /etc/apt/sources.list.d/ ]]; then grep ^ /etc/apt/sources.list /etc/apt/sources.list.d/* | grep -Fq "$repo" && log_info "${APTFILE_CYAN}[OK]${APTFILE_COLOR_OFF} repository $repo" && return 0 fi - add-apt-repository -y "$repo" > "$TMP_APTFILE_LOGFILE" 2>&1 + add-apt-repository -y "$repo" >"$TMP_APTFILE_LOGFILE" 2>&1 + [[ $? -eq 0 ]] || log_fail "${APTFILE_RED}[FAIL]${APTFILE_COLOR_OFF} repository $pkg" + update + log_info "${APTFILE_GREEN}[NEW]${APTFILE_COLOR_OFF} repository $repo" +} + +repository_file() { + [[ $TRACE ]] && set -x + [[ -z $2 ]] && log_fail "Please specify a filename and sourceline to setup" + local repofile="$1" + local repo="$2" + # sourceline is not a complete repo configuration, needs modifying + # i.e. not sourceline="deb http://domain.invalid/debian buster main extra" + if [[ "$repo" != "deb "* ]]; then + releasename=$(lsb_release -sc) + if [[ "$repo" == *" "* ]]; then + # Components given in sourceline, adding suite + # i.e. sourceline="http://domain.invalid/debian main" + repo="deb ${repo/ / $releasename }" + else + # only URL given, adding suite and component + # i.e. sourceline="http://domain.invalid/debian" + repo="deb ${repo} $releasename main" + fi + fi + + if [[ "$repofile" != *.list ]]; then + # Adding extension to enable parsing file + repofile=${repofile}.list + fi + # Adding path + repofile="/etc/apt/sources.list.d/$repofile" + + [[ -d "/etc/apt/sources.list.d" ]] || mkdir -p /etc/apt/sources.list.d + + grep ^ /etc/apt/sources.list /etc/apt/sources.list.d/* | grep -Fq "$repo" && log_info "${APTFILE_CYAN}[OK]${APTFILE_COLOR_OFF} repository $repo" && return 0 + + echo "Writing '$repo' to file '$repofile'" >"$TMP_APTFILE_LOGFILE" + echo "$repo" >"$repofile" 2>>"$TMP_APTFILE_LOGFILE" [[ $? -eq 0 ]] || log_fail "${APTFILE_RED}[FAIL]${APTFILE_COLOR_OFF} repository $pkg" update log_info "${APTFILE_GREEN}[NEW]${APTFILE_COLOR_OFF} repository $repo" @@ -183,7 +265,7 @@ APTFILE_TMPNAME="$APTFILE_TMPDIR/aptfile.$$" APTFILE_OUTPUT="${APTFILE_TMPNAME}.out" aptfile_preprocess_source() { - tail -n +2 "$1" > "$APTFILE_OUTPUT" + tail -n +2 "$1" >"$APTFILE_OUTPUT" trap "aptfile_cleanup_preprocessed_source" err exit trap "aptfile_cleanup_preprocessed_source; exit 1" int } @@ -197,8 +279,11 @@ aptfile_preprocess_source "$APTFILE_INPUT" export -f update export -f package +export -f package_from_url +export -f packagelist export -f ppa export -f repository +export -f repository_file export -f debconf_selection export -f log_fail export -f log_info From 6300e1d67788da93d8d308df302353f9f5b1743a Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 16 Feb 2024 20:37:58 -0600 Subject: [PATCH 07/37] Update requirements.txt update RPi.GPIO requirements --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index e40b8fc3..76bbcb62 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,7 @@ noaa-sdk>=0.1.18 pyowm>=3.0.0 python-tsl2591==0.2.0 regex>=2020.4.4 -RPi.GPIO==0.7.0 +RPi.GPIO>=0.7.1 APScheduler==3.10.4 lastversion>=1.1.6 nameparser>=1.0.6 @@ -18,4 +18,4 @@ iso6709 cairosvg tzlocal rich -diskcache \ No newline at end of file +diskcache From 55e5cb2f4b38c53aac4fba2fc15ce33179787794 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 16 Feb 2024 20:58:15 -0600 Subject: [PATCH 08/37] tweaks to install_venv for autoactivating venv --- scripts/install_venv.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/install_venv.sh b/scripts/install_venv.sh index 4ee7d5b7..2d876440 100755 --- a/scripts/install_venv.sh +++ b/scripts/install_venv.sh @@ -25,9 +25,23 @@ python3 -m venv $HOME/nhlsb-venv --system-site-packages tput bold; echo "$(tput setaf 2)Activating direnv for python venv...$(tput setaf 9)" ; tput sgr0 echo "export VIRTUAL_ENV=~/nhlsb-venv" >> .envrc -echo "layout python" >> .envrc +echo "source ~/nhlsb-venv/bin/activate" >> .envrc direnv allow . +# Update bashrc +tee ~/.bashrc << TEXT0 +show_virtual_env() { + if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then + echo "($(basename $VIRTUAL_ENV)) " + fi +} +export -f show_virtual_env +PS1='$(show_virtual_env)'$PS1 + +eval "$(direnv hook bash)" + +TEXT0 + echo "$(tput setaf 6)Activating python virtual environment...$(tput setaf 9)" source $HOME/nhlsb-venv/bin/activate From 5a271370db6da5ad520e9c16ce46eda3a7b13d96 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 16 Feb 2024 21:02:09 -0600 Subject: [PATCH 09/37] more tweaks to install_venv --- scripts/install_venv.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/install_venv.sh b/scripts/install_venv.sh index 2d876440..58cb580d 100755 --- a/scripts/install_venv.sh +++ b/scripts/install_venv.sh @@ -103,8 +103,10 @@ git pull tput bold; echo "$(tput setaf 6)If you didn't see any errors above, everything should be installed!"; tput sgr0 echo "$(tput bold)$(tput smso)$(tput setaf 2)Installation complete!$(tput sgr0) Play around with the examples in nhl-led-scoreboard/submodules/matrix/bindings/python/samples to make sure your matrix is working." +tput bold; echo "$(tput setaf 4)...................................................$(tput setaf 9)" ; tput sgr0 tput bold; echo "$(tput setaf 4)TAKE NOTE OF NEXT LINES...$(tput setaf 9)" ; tput sgr0 tput bold; echo "$(tput setaf 4)WITh A VENV, Your python is now located differently...$(tput setaf 9)" ; tput sgr0 tput bold; echo "$(tput setaf 4)TO RUN WITH SUDO, YOU MUST USE THE VENV LOCATION...$(tput setaf 9)" ; tput sgr0 -tput bold; echo "$(tput setaf 4)...................................................$(tput setaf 9)" ; tput sgr0 +tput bold; echo "$(tput setaf 4).................PYTHON LOOKS LIKE.....................$(tput setaf 9)" ; tput sgr0 tput bold; echo "$(tput setaf 1)sudo $HOME/nhlsb-venv/bin/python3 $(tput setaf 9)" ; tput sgr0 +tput bold; echo "$(tput setaf 4)...................................................$(tput setaf 9)" ; tput sgr0 From 6c3d39d1b4c7cb44f8a90a51bce2fa05c61ef332 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 16 Feb 2024 21:07:35 -0600 Subject: [PATCH 10/37] Remove extra nhl-led-scoreboard directory that was create incorrectly --- nhl-led-scoreboard | 1 - 1 file changed, 1 deletion(-) delete mode 160000 nhl-led-scoreboard diff --git a/nhl-led-scoreboard b/nhl-led-scoreboard deleted file mode 160000 index 33363610..00000000 --- a/nhl-led-scoreboard +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3336361004831fffb0ee596a36bce6ff89c0ced2 From ddba8e252b2b4f089dfa8d7770842b748a2b8706 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 16 Feb 2024 21:10:15 -0600 Subject: [PATCH 11/37] Update apt-requirements Typos --- apt-requirements | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-requirements b/apt-requirements index 4f3636bf..9d3bebfa 100644 --- a/apt-requirements +++ b/apt-requirements @@ -29,7 +29,7 @@ package "zsh" package "dbus" package "libdbus-glib-1-dev" package "libgirepository1.0-dev" -pacakge "libdbus-1-dev" +package "libdbus-1-dev" # you can also execute arbitrary bash echo "🚨 ALL GOOD TO GO" From a417ccdbd660082679383f4087e1334a61f2e2be Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 16 Feb 2024 21:44:19 -0600 Subject: [PATCH 12/37] Update install_venv.sh --- scripts/install_venv.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_venv.sh b/scripts/install_venv.sh index 58cb580d..243cdfbd 100755 --- a/scripts/install_venv.sh +++ b/scripts/install_venv.sh @@ -29,7 +29,7 @@ echo "source ~/nhlsb-venv/bin/activate" >> .envrc direnv allow . # Update bashrc -tee ~/.bashrc << TEXT0 +tee -a ~/.bashrc << 'TEXT0' show_virtual_env() { if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then echo "($(basename $VIRTUAL_ENV)) " From 503e9431b1659b41967a788564028c157743bf63 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Mon, 19 Feb 2024 20:41:51 -0600 Subject: [PATCH 13/37] Update sb-upgrade script to upgrade python libraries rather than just installing them. --- scripts/sbtools/sb-upgrade | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/sbtools/sb-upgrade b/scripts/sbtools/sb-upgrade index b05a9c8c..5b5c6e3a 100755 --- a/scripts/sbtools/sb-upgrade +++ b/scripts/sbtools/sb-upgrade @@ -2,10 +2,10 @@ # Borrowed from oh-my-zsh # https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/upgrade.sh -cd /home/pi/nhl-led-scoreboard +#cd /home/pi/nhl-led-scoreboard #Uncomment for running out of the repository scripts/sbtools directory -#DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -#cd "${DIR}" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +cd "${DIR}" # Use colors, but only if connected to a terminal # and that terminal supports them. @@ -87,7 +87,7 @@ if git pull --rebase --stat origin master; then #Check to see if the requirements.txt has changed, if so, run the pip3 install -r requirements.txt again if ! git diff -s --exit-code HEAD "$last_commit" requirements.txt; then printf "${GREEN}%s${RESET}\n" "New python library requirements for this version, installing now" - sudo pip3 install -r requirements.txt + sudo pip3 install -U -r requirements.txt else printf "${YELLOW}%s${RESET}\n" "No new python libraries required to be installed." fi From a7efc7feb6598762c5e1e2cfb1b05f69c94faddc Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Wed, 21 Feb 2024 10:45:08 -0600 Subject: [PATCH 14/37] Update requirements.txt Update env_canada library to force newest version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 76bbcb62..63d52489 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -env-canada +env-canada>=0.6.1 ephem fastjsonschema>=2.14.4 geocoder>=1.38.1 From ebdcfbad79d7f61d16b0698eaf4ab847aa51e232 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Wed, 21 Feb 2024 16:26:12 -0600 Subject: [PATCH 15/37] Update install_venv.sh Uodate .bashrc to disable the direnv output --- scripts/install_venv.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install_venv.sh b/scripts/install_venv.sh index 243cdfbd..4bb914af 100755 --- a/scripts/install_venv.sh +++ b/scripts/install_venv.sh @@ -38,6 +38,7 @@ show_virtual_env() { export -f show_virtual_env PS1='$(show_virtual_env)'$PS1 +export DIRENV_LOG_FORMAT= eval "$(direnv hook bash)" TEXT0 From 015bd4960ac5874fe01944db2c9f1fefc47ffa77 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Wed, 21 Feb 2024 16:38:14 -0600 Subject: [PATCH 16/37] Update sb-upgrade Added check to see if virtual environment is active --- scripts/sbtools/sb-upgrade | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/sbtools/sb-upgrade b/scripts/sbtools/sb-upgrade index 5b5c6e3a..54e1d290 100755 --- a/scripts/sbtools/sb-upgrade +++ b/scripts/sbtools/sb-upgrade @@ -87,7 +87,11 @@ if git pull --rebase --stat origin master; then #Check to see if the requirements.txt has changed, if so, run the pip3 install -r requirements.txt again if ! git diff -s --exit-code HEAD "$last_commit" requirements.txt; then printf "${GREEN}%s${RESET}\n" "New python library requirements for this version, installing now" - sudo pip3 install -U -r requirements.txt + if [ -n "$VIRTUAL_ENV" ] ; + sudo pip3 install -U -r requirements.txt + else + pip3 install -U -r requirements.txt + fi else printf "${YELLOW}%s${RESET}\n" "No new python libraries required to be installed." fi From 2b154fd7650bce2007d08346271f9c4c644a6ef0 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Thu, 22 Feb 2024 18:07:33 -0600 Subject: [PATCH 17/37] Changing up the install script to use the sb-init or sb-upgrade scripts instead --- scripts/install.sh | 94 ++++++++++++++------ scripts/sbtools/config_novenv.sh | 49 ++++++++++ scripts/{install_venv.sh => sbtools/sb-init} | 22 ++++- 3 files changed, 138 insertions(+), 27 deletions(-) create mode 100755 scripts/sbtools/config_novenv.sh rename scripts/{install_venv.sh => sbtools/sb-init} (84%) diff --git a/scripts/install.sh b/scripts/install.sh index c378a6ae..add44073 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,41 +1,85 @@ -#!/bin/bash +#! /bin/bash # Make script work regardless of where it is run from DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" cd "${DIR}/.." || exit -echo "$(tput setaf 6)Installing required dependencies. This may take some time (10-20 minutes-ish)...$(tput setaf 9)" -#Install all apt requirements using aptfile -sudo scripts/aptfile apt-requirements +deb_ver () { + ver=$(cut -d . -f 1 < /etc/debian_version) + echo $ver +} -#Install all pip3 requirements using the requirements.txt filer -sudo pip3 install -r requirements.txt +deb_name () { + . /etc/os-release; echo "$PRETTY_NAME" +} -# Pull submodule and ignore changes from script -git submodule update --init --recursive -git config submodule.matrix.ignore all +py_ver () { + pyver="$(command -p python3 -V | sed 's/Python //g')" + echo $pyver +} -echo "$(tput setaf 4)Running rgbmatrix installation...$(tput setaf 9)" +show_virtual_env() { + if [ -n "$VIRTUAL_ENV" ]; then + echo "VENV name: $(basename $VIRTUAL_ENV)" + else + echo "No VENV installed" + fi +} -# Recompile the cpp files to build library with newest cython. See https://github.com/hzeller/rpi-rgb-led-matrix/issues/1298 +py_loc () { + pyloc="$(command -v python3)" + echo $pyloc +} -cd submodules/matrix/bindings/python/rgbmatrix/ || exit +get_model() { + pimodel=$(tr -d '\0' &1 1>&2 2>&3) + + RET=$? + + if [ $RET -eq 1 ]; then + exit 0 + elif [ $RET -eq 0 ]; then + case "$FUN" in + 1\ *) do_install ;; + 2\ *) do_upgrade ;; + 3\ *) do_about ;; + *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; + esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1 + else + exit 1 + fi +done diff --git a/scripts/sbtools/config_novenv.sh b/scripts/sbtools/config_novenv.sh new file mode 100755 index 00000000..1b9c62b9 --- /dev/null +++ b/scripts/sbtools/config_novenv.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# Make script work regardless of where it is run from +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +cd "${DIR}/.." || exit + +if (whiptail --title "New install?" --yesno "Is this a new install?" 8 78); then + tput bold; echo "$(tput setaf 2)Installing required OS dependencies. This may take some time (10-20 minutes-ish)...$(tput setaf 9)" ; tput sgr0 +else + whiptail --msgbox "To upgrade, run scripts/sbtools/sb-upgrade instead..." 25 80 + tput bold; echo "$(tput setaf 2)To upgrade, run scripts/sbtools/sb-upgrade instead...$(tput setaf 9)" ; tput sgr0 + exit +fi + +echo "$(tput setaf 6)Installing required dependencies. This may take some time (10-20 minutes-ish)...$(tput setaf 9)" +#Install all apt requirements using aptfile +sudo scripts/aptfile apt-requirements + +#Install all pip3 requirements using the requirements.txt filer +sudo pip3 install -r requirements.txt + +# Pull submodule and ignore changes from script +git submodule update --init --recursive +git config submodule.matrix.ignore all + +echo "$(tput setaf 4)Running rgbmatrix installation...$(tput setaf 9)" + +# Recompile the cpp files to build library with newest cython. See https://github.com/hzeller/rpi-rgb-led-matrix/issues/1298 + +cd submodules/matrix/bindings/python/rgbmatrix/ || exit + +# The following lines are no longer necessary +# python3 -m pip install --no-cache-dir cython +# python3 -m cython -2 --cplus *.pyx + +cd ../../../ || exit + +make build-python PYTHON="$(command -v python3)" +sudo make install-python PYTHON="$(command -v python3)" + +cd ../../../ || exit + +git reset --hard +git fetch origin --prune +git pull + +make +echo "If you didn't see any errors above, everything should be installed!" +echo "$(tput bold)$(tput smso)$(tput setaf 2)Installation complete!$(tput sgr0) Play around with the examples in nhl-led-scoreboard/submodules/matrix/bindings/python/samples to make sure your matrix is working." diff --git a/scripts/install_venv.sh b/scripts/sbtools/sb-init similarity index 84% rename from scripts/install_venv.sh rename to scripts/sbtools/sb-init index 4bb914af..c96097c2 100755 --- a/scripts/install_venv.sh +++ b/scripts/sbtools/sb-init @@ -1,9 +1,29 @@ #!/bin/bash +# Functions +py_ver () { + pyver="$(command -p python3 -V | sed 's/Python //g')" + echo $pyver +} + # Make script work regardless of where it is run from DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" cd "${DIR}/.." || exit +#if (whiptail --title "New install?" --yesno "Is this a new install?" 8 78); then +# tput bold; echo "$(tput setaf 2)Installing required OS dependencies. This may take some time (10-20 minutes-ish)...$(tput setaf 9)" ; tput sgr0 +#else +# whiptail --msgbox "To upgrade, run scripts/sbtools/sb-upgrade instead..." 25 80 +# tput bold; echo "$(tput setaf 2)To upgrade, run scripts/sbtools/sb-upgrade instead...$(tput setaf 9)" ; tput sgr0 +# exit +#fi + +# Everything else needs to be run as root +if [ $(id -u) -eq 0 ]; then + tput bold; echo "$(tput setaf 9)You do not need to run this script using sudo, it will handle sudo as required$(tput setaf 9)" ; tput sgr0 + exit 1 +fi + tput bold; echo "$(tput setaf 2)Installing required OS dependencies. This may take some time (10-20 minutes-ish)...$(tput setaf 9)" ; tput sgr0 #Install all apt requirements using aptfile @@ -11,8 +31,6 @@ sudo scripts/aptfile apt-requirements tput bold; echo "$(tput setaf 2)Creating python virtual environment...$(tput setaf 9)" ; tput sgr0 -#Install all apt requirements using aptfile -#sudo scripts/aptfile apt-requirements # Update system pip3 to latest version python3 -m pip install --upgrade pip --break-system-packages From 3bd3966dea0a038621537d7354e84f768a9dda71 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Thu, 22 Feb 2024 19:30:05 -0600 Subject: [PATCH 18/37] Retooling of install scripts --- scripts/install.sh | 20 ++++++- scripts/sbtools/sb-init | 110 ++++++++++++++++++++----------------- scripts/sbtools/sb-upgrade | 14 +++-- 3 files changed, 90 insertions(+), 54 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index add44073..b7d90cec 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -4,6 +4,12 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" cd "${DIR}/.." || exit +# Don't run as root user +if [ $(id -u) -eq 0 ]; then + tput bold; echo "$(tput setaf 9)You do not need to run this script using sudo, it will handle sudo as required$(tput setaf 9)" ; tput sgr0 + exit 1 +fi + deb_ver () { ver=$(cut -d . -f 1 < /etc/debian_version) echo $ver @@ -53,7 +59,19 @@ calc_wt_size() { } do_install() { - if $(dpkg --compare-versions $(py_ver) "gt" "3.9.0"); then echo true; else echo false; fi + scripts/sb-init +} + +do_upgrade() { + scripts/sb-upgrade +} + +do_help() { + whiptail --msgbox "\ +This tool provides a straightforward way of doing initial +install of the NHL LED Scoreboard or an Upgrade of an existing installation\ +" 20 70 1 + return 0 } calc_wt_size diff --git a/scripts/sbtools/sb-init b/scripts/sbtools/sb-init index c96097c2..6cc89225 100755 --- a/scripts/sbtools/sb-init +++ b/scripts/sbtools/sb-init @@ -18,7 +18,7 @@ cd "${DIR}/.." || exit # exit #fi -# Everything else needs to be run as root +# Don't run as root if [ $(id -u) -eq 0 ]; then tput bold; echo "$(tput setaf 9)You do not need to run this script using sudo, it will handle sudo as required$(tput setaf 9)" ; tput sgr0 exit 1 @@ -29,51 +29,62 @@ tput bold; echo "$(tput setaf 2)Installing required OS dependencies. This may ta #Install all apt requirements using aptfile sudo scripts/aptfile apt-requirements -tput bold; echo "$(tput setaf 2)Creating python virtual environment...$(tput setaf 9)" ; tput sgr0 - - -# Update system pip3 to latest version -python3 -m pip install --upgrade pip --break-system-packages - -# Install virtual enviroment, required for upcoming bookworm release -# Use already installed site-packages that were installed as part o fthe apt OS dependencies -python3 -m venv $HOME/nhlsb-venv --system-site-packages - -# Activate the direnv to allow for automatic activate and deactivate of venv -tput bold; echo "$(tput setaf 2)Activating direnv for python venv...$(tput setaf 9)" ; tput sgr0 - -echo "export VIRTUAL_ENV=~/nhlsb-venv" >> .envrc -echo "source ~/nhlsb-venv/bin/activate" >> .envrc -direnv allow . - -# Update bashrc -tee -a ~/.bashrc << 'TEXT0' -show_virtual_env() { - if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then - echo "($(basename $VIRTUAL_ENV)) " - fi -} -export -f show_virtual_env -PS1='$(show_virtual_env)'$PS1 - -export DIRENV_LOG_FORMAT= -eval "$(direnv hook bash)" - +# Check python version, if it's greater than 3.9, we will create a venv, if not, we will follow normal install but really should push +# users to using a venv +if $(dpkg --compare-versions $(py_ver) "gt" "3.9.0"); then + tput bold; echo "$(tput setaf 2)Creating python virtual environment...$(tput setaf 9)" ; tput sgr0 + + # Update system pip3 to latest version + python3 -m pip install --upgrade pip --break-system-packages + + # Install virtual enviroment, required for upcoming bookworm release + # Use already installed site-packages that were installed as part o fthe apt OS dependencies + python3 -m venv $HOME/nhlsb-venv --system-site-packages + + # Activate the direnv to allow for automatic activate and deactivate of venv + tput bold; echo "$(tput setaf 2)Activating direnv for python venv...$(tput setaf 9)" ; tput sgr0 + + echo "export VIRTUAL_ENV=~/nhlsb-venv" >> .envrc + echo "source ~/nhlsb-venv/bin/activate" >> .envrc + direnv allow . + + # Update bashrc + tee -a ~/.bashrc << 'TEXT0' + show_virtual_env() { + if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then + echo "($(basename $VIRTUAL_ENV)) " + fi + } + export -f show_virtual_env + PS1='$(show_virtual_env)'$PS1 + + export DIRENV_LOG_FORMAT= + eval "$(direnv hook bash)" TEXT0 -echo "$(tput setaf 6)Activating python virtual environment...$(tput setaf 9)" + echo "$(tput setaf 6)Activating python virtual environment...$(tput setaf 9)" -source $HOME/nhlsb-venv/bin/activate + source $HOME/nhlsb-venv/bin/activate -echo "$(tput setaf 6)Updating pip in virtual environment...$(tput setaf 9)" -# Update pip in the virtual enviroment -python3 -m pip install --upgrade pip -#Install all pip3 requirements using the requirements.txt file -#This will install into the virtual environment + echo "$(tput setaf 6)Updating pip in virtual environment...$(tput setaf 9)" + # Update pip in the virtual enviroment + python3 -m pip install --upgrade pip + #Install all pip3 requirements using the requirements.txt file + #This will install into the virtual environment -tput bold; echo "$(tput setaf 2)Installing scoreboard python requirements in virtual environment...$(tput setaf 9)" ; tput sgr0 -pip3 install -r requirements.txt + tput bold; echo "$(tput setaf 2)Installing scoreboard python requirements in virtual environment...$(tput setaf 9)" ; tput sgr0 + pip3 install -r requirements.txt + tput bold; echo "$(tput setaf 4)...................................................$(tput setaf 9)" ; tput sgr0 + tput bold; echo "$(tput setaf 4)TAKE NOTE OF NEXT LINES...$(tput setaf 9)" ; tput sgr0 + tput bold; echo "$(tput setaf 4)WITh A VENV, Your python is now located differently...$(tput setaf 9)" ; tput sgr0 + tput bold; echo "$(tput setaf 4)TO RUN WITH SUDO, YOU MUST USE THE VENV LOCATION...$(tput setaf 9)" ; tput sgr0 + tput bold; echo "$(tput setaf 4).................PYTHON LOOKS LIKE.....................$(tput setaf 9)" ; tput sgr0 + tput bold; echo "$(tput setaf 1)sudo $HOME/nhlsb-venv/bin/python3 $(tput setaf 9)" ; tput sgr0 + tput bold; echo "$(tput setaf 4)...................................................$(tput setaf 9)" ; tput sgr0 +else + sudo pip3 install -r requirements.txt +fi # Pull submodule and ignore changes from script git submodule update --init --recursive git config submodule.matrix.ignore all @@ -91,10 +102,17 @@ cd submodules/matrix/ || exit # cd ../../ || exit make build-python PYTHON="$(command -v python3)" -make install-python PYTHON="$(command -v python3)" + +if [ -n "$VIRTUAL_ENV" ]; then + #make install-python PYTHON="$(command -v python3)" + pip3 install bindings/python/ +else + sudo pip3 install bindings/python/ +fi cd ../../ || exit +tput bold; echo "$(tput setaf 4)Blacklisting sound module...$(tput setaf 9)" ; tput sgr0 # Blacklist the snd_bcm2835 sounds module sudo tee /etc/modprobe.d/blacklist-rgbmatrix.conf </dev/null 2>&1 && pwd )" cd "${DIR}" +# Don't run as root +if [ $(id -u) -eq 0 ]; then + tput bold; echo "$(tput setaf 9)You do not need to run this script using sudo, it will handle sudo as required$(tput setaf 9)" ; tput sgr0 + exit 1 +fi + # Use colors, but only if connected to a terminal # and that terminal supports them. @@ -87,10 +93,10 @@ if git pull --rebase --stat origin master; then #Check to see if the requirements.txt has changed, if so, run the pip3 install -r requirements.txt again if ! git diff -s --exit-code HEAD "$last_commit" requirements.txt; then printf "${GREEN}%s${RESET}\n" "New python library requirements for this version, installing now" - if [ -n "$VIRTUAL_ENV" ] ; - sudo pip3 install -U -r requirements.txt - else - pip3 install -U -r requirements.txt + if [ -n "$VIRTUAL_ENV" ]; then + pip3 install -U -r requirements.txt + else + sudo pip3 install -U -r requirements.txt fi else printf "${YELLOW}%s${RESET}\n" "No new python libraries required to be installed." From 6957516f13d2f66bfda0c04e49d1d1e73fd94051 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Thu, 22 Feb 2024 19:34:42 -0600 Subject: [PATCH 19/37] Add messagebox to sb-init for when VENV is created --- scripts/sbtools/sb-init | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/sbtools/sb-init b/scripts/sbtools/sb-init index 6cc89225..1057b658 100755 --- a/scripts/sbtools/sb-init +++ b/scripts/sbtools/sb-init @@ -75,9 +75,16 @@ TEXT0 tput bold; echo "$(tput setaf 2)Installing scoreboard python requirements in virtual environment...$(tput setaf 9)" ; tput sgr0 pip3 install -r requirements.txt + whiptail --msgbox "\ + WITH A VENV, Your python is now located differently...\ + TO RUN WITH SUDO, YOU MUST USE THE VENV LOCATION...\ + .................PYTHON LOOKS LIKE.....................\ + sudo $HOME/nhlsb-venv/bin/python3\ + ..................................................." + tput bold; echo "$(tput setaf 4)...................................................$(tput setaf 9)" ; tput sgr0 tput bold; echo "$(tput setaf 4)TAKE NOTE OF NEXT LINES...$(tput setaf 9)" ; tput sgr0 - tput bold; echo "$(tput setaf 4)WITh A VENV, Your python is now located differently...$(tput setaf 9)" ; tput sgr0 + tput bold; echo "$(tput setaf 4)WITH A VENV, Your python is now located differently...$(tput setaf 9)" ; tput sgr0 tput bold; echo "$(tput setaf 4)TO RUN WITH SUDO, YOU MUST USE THE VENV LOCATION...$(tput setaf 9)" ; tput sgr0 tput bold; echo "$(tput setaf 4).................PYTHON LOOKS LIKE.....................$(tput setaf 9)" ; tput sgr0 tput bold; echo "$(tput setaf 1)sudo $HOME/nhlsb-venv/bin/python3 $(tput setaf 9)" ; tput sgr0 From b3a3ab3b0587d24361a566dc443d0cd855918c36 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Thu, 22 Feb 2024 19:38:30 -0600 Subject: [PATCH 20/37] Update install.sh --- scripts/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install.sh b/scripts/install.sh index b7d90cec..f00491bb 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -94,7 +94,7 @@ while true; do case "$FUN" in 1\ *) do_install ;; 2\ *) do_upgrade ;; - 3\ *) do_about ;; + 3\ *) do_help ;; *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1 else From f07ed7cc0f251ee9da26b0f885b3a7b68393a113 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Thu, 22 Feb 2024 19:39:37 -0600 Subject: [PATCH 21/37] Update install.sh --- scripts/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index f00491bb..85ff5f2f 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -59,11 +59,11 @@ calc_wt_size() { } do_install() { - scripts/sb-init + scripts/sbtools/sb-init } do_upgrade() { - scripts/sb-upgrade + scripts/sbtools/sb-upgrade } do_help() { From 1e768c9411aad7485f16f00cf86136be533fd9bd Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Thu, 22 Feb 2024 19:43:27 -0600 Subject: [PATCH 22/37] Update sb-upgrade --- scripts/sbtools/sb-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sbtools/sb-upgrade b/scripts/sbtools/sb-upgrade index 7c57eb6c..e62559d7 100755 --- a/scripts/sbtools/sb-upgrade +++ b/scripts/sbtools/sb-upgrade @@ -67,7 +67,7 @@ git config rebase.autoStash true local ret=0 # Update nhl-led-scoreboard -printf "${BLUE}%s${RESET}\n" "Updating NHL LED Scoreboard" +printf "${GREEN}%s${RESET}\n" "Updating NHL LED Scoreboard" last_commit=$(git rev-parse HEAD) if git pull --rebase --stat origin master; then # Check if it was really updated or not From f94245204b50a29bf82e169c43f90ac5405d40de Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Thu, 22 Feb 2024 20:16:14 -0600 Subject: [PATCH 23/37] More install.sh tweaks --- scripts/{ => sbtools}/aptfile | 0 scripts/sbtools/sb-init | 32 ++++++++++++-------------------- scripts/sbtools/sb-upgrade | 2 +- 3 files changed, 13 insertions(+), 21 deletions(-) rename scripts/{ => sbtools}/aptfile (100%) diff --git a/scripts/aptfile b/scripts/sbtools/aptfile similarity index 100% rename from scripts/aptfile rename to scripts/sbtools/aptfile diff --git a/scripts/sbtools/sb-init b/scripts/sbtools/sb-init index 1057b658..611955f7 100755 --- a/scripts/sbtools/sb-init +++ b/scripts/sbtools/sb-init @@ -8,15 +8,7 @@ py_ver () { # Make script work regardless of where it is run from DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -cd "${DIR}/.." || exit - -#if (whiptail --title "New install?" --yesno "Is this a new install?" 8 78); then -# tput bold; echo "$(tput setaf 2)Installing required OS dependencies. This may take some time (10-20 minutes-ish)...$(tput setaf 9)" ; tput sgr0 -#else -# whiptail --msgbox "To upgrade, run scripts/sbtools/sb-upgrade instead..." 25 80 -# tput bold; echo "$(tput setaf 2)To upgrade, run scripts/sbtools/sb-upgrade instead...$(tput setaf 9)" ; tput sgr0 -# exit -#fi +cd "${DIR}/../.." # Don't run as root if [ $(id -u) -eq 0 ]; then @@ -27,16 +19,16 @@ fi tput bold; echo "$(tput setaf 2)Installing required OS dependencies. This may take some time (10-20 minutes-ish)...$(tput setaf 9)" ; tput sgr0 #Install all apt requirements using aptfile -sudo scripts/aptfile apt-requirements +sudo $DIR/aptfile apt-requirements + +# Update system pip3 to latest version +sudo python3 -m pip install --upgrade pip --break-system-packages # Check python version, if it's greater than 3.9, we will create a venv, if not, we will follow normal install but really should push # users to using a venv if $(dpkg --compare-versions $(py_ver) "gt" "3.9.0"); then tput bold; echo "$(tput setaf 2)Creating python virtual environment...$(tput setaf 9)" ; tput sgr0 - # Update system pip3 to latest version - python3 -m pip install --upgrade pip --break-system-packages - # Install virtual enviroment, required for upcoming bookworm release # Use already installed site-packages that were installed as part o fthe apt OS dependencies python3 -m venv $HOME/nhlsb-venv --system-site-packages @@ -50,16 +42,16 @@ if $(dpkg --compare-versions $(py_ver) "gt" "3.9.0"); then # Update bashrc tee -a ~/.bashrc << 'TEXT0' - show_virtual_env() { - if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then +show_virtual_env() { + if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then echo "($(basename $VIRTUAL_ENV)) " fi - } - export -f show_virtual_env - PS1='$(show_virtual_env)'$PS1 +} +export -f show_virtual_env +PS1='$(show_virtual_env)'$PS1 - export DIRENV_LOG_FORMAT= - eval "$(direnv hook bash)" +export DIRENV_LOG_FORMAT= +eval "$(direnv hook bash)" TEXT0 echo "$(tput setaf 6)Activating python virtual environment...$(tput setaf 9)" diff --git a/scripts/sbtools/sb-upgrade b/scripts/sbtools/sb-upgrade index 7c57eb6c..936b1632 100755 --- a/scripts/sbtools/sb-upgrade +++ b/scripts/sbtools/sb-upgrade @@ -67,7 +67,7 @@ git config rebase.autoStash true local ret=0 # Update nhl-led-scoreboard -printf "${BLUE}%s${RESET}\n" "Updating NHL LED Scoreboard" +printf "${GREEN}%s${RESET}\n" "Checking to see if we can updtae NHL LED Scoreboard" last_commit=$(git rev-parse HEAD) if git pull --rebase --stat origin master; then # Check if it was really updated or not From 3b613c51df794da0e6ab27c8b1a2aea4d5142ad1 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Thu, 22 Feb 2024 20:25:53 -0600 Subject: [PATCH 24/37] Update sb-init remove whiptail mesbox --- scripts/sbtools/sb-init | 7 ------- 1 file changed, 7 deletions(-) diff --git a/scripts/sbtools/sb-init b/scripts/sbtools/sb-init index 611955f7..e89d919f 100755 --- a/scripts/sbtools/sb-init +++ b/scripts/sbtools/sb-init @@ -66,13 +66,6 @@ TEXT0 tput bold; echo "$(tput setaf 2)Installing scoreboard python requirements in virtual environment...$(tput setaf 9)" ; tput sgr0 pip3 install -r requirements.txt - - whiptail --msgbox "\ - WITH A VENV, Your python is now located differently...\ - TO RUN WITH SUDO, YOU MUST USE THE VENV LOCATION...\ - .................PYTHON LOOKS LIKE.....................\ - sudo $HOME/nhlsb-venv/bin/python3\ - ..................................................." tput bold; echo "$(tput setaf 4)...................................................$(tput setaf 9)" ; tput sgr0 tput bold; echo "$(tput setaf 4)TAKE NOTE OF NEXT LINES...$(tput setaf 9)" ; tput sgr0 From 2405cbda2c4f210d4d7b1b11ad349568c1a0be65 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Thu, 22 Feb 2024 20:44:16 -0600 Subject: [PATCH 25/37] Only add to .bashrc if it was updated already --- scripts/sbtools/sb-init | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/sbtools/sb-init b/scripts/sbtools/sb-init index e89d919f..740d43c7 100755 --- a/scripts/sbtools/sb-init +++ b/scripts/sbtools/sb-init @@ -39,9 +39,10 @@ if $(dpkg --compare-versions $(py_ver) "gt" "3.9.0"); then echo "export VIRTUAL_ENV=~/nhlsb-venv" >> .envrc echo "source ~/nhlsb-venv/bin/activate" >> .envrc direnv allow . - + if grep -q sb-init ~/.bashrc; then # Update bashrc tee -a ~/.bashrc << 'TEXT0' +# ADDED BY sb-init script for nhl-led-scoreboard show_virtual_env() { if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then echo "($(basename $VIRTUAL_ENV)) " @@ -53,6 +54,7 @@ PS1='$(show_virtual_env)'$PS1 export DIRENV_LOG_FORMAT= eval "$(direnv hook bash)" TEXT0 + fi echo "$(tput setaf 6)Activating python virtual environment...$(tput setaf 9)" From 5b4ae33ccb663ba99dca49371905e2655fad8fbc Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Thu, 22 Feb 2024 20:57:14 -0600 Subject: [PATCH 26/37] Update sb-init --- scripts/sbtools/sb-init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sbtools/sb-init b/scripts/sbtools/sb-init index 740d43c7..058d6f8c 100755 --- a/scripts/sbtools/sb-init +++ b/scripts/sbtools/sb-init @@ -39,7 +39,7 @@ if $(dpkg --compare-versions $(py_ver) "gt" "3.9.0"); then echo "export VIRTUAL_ENV=~/nhlsb-venv" >> .envrc echo "source ~/nhlsb-venv/bin/activate" >> .envrc direnv allow . - if grep -q sb-init ~/.bashrc; then + if ! grep -q sb-init ~/.bashrc; then # Update bashrc tee -a ~/.bashrc << 'TEXT0' # ADDED BY sb-init script for nhl-led-scoreboard From 32d7ad6d07e5b0cc37399bb29c00f4f82a948b61 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 23 Feb 2024 11:23:12 -0600 Subject: [PATCH 27/37] Update to look at python version higher than 3.10.0 in order to install the venv --- scripts/sbtools/sb-init | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/sbtools/sb-init b/scripts/sbtools/sb-init index 058d6f8c..d44cd4b3 100755 --- a/scripts/sbtools/sb-init +++ b/scripts/sbtools/sb-init @@ -24,9 +24,9 @@ sudo $DIR/aptfile apt-requirements # Update system pip3 to latest version sudo python3 -m pip install --upgrade pip --break-system-packages -# Check python version, if it's greater than 3.9, we will create a venv, if not, we will follow normal install but really should push +# Check python version, if it's greater than 3.9 (bullseye version), we will create a venv, if not, we will follow normal install but really should push # users to using a venv -if $(dpkg --compare-versions $(py_ver) "gt" "3.9.0"); then +if $(dpkg --compare-versions $(py_ver) "gt" "3.10.0"); then tput bold; echo "$(tput setaf 2)Creating python virtual environment...$(tput setaf 9)" ; tput sgr0 # Install virtual enviroment, required for upcoming bookworm release From 93b6689720e510265142a700e53fc4cec287660c Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 23 Feb 2024 11:28:13 -0600 Subject: [PATCH 28/37] Change update of system wide pip to look at version of python install so the --break-system-packages is used right --- scripts/sbtools/sb-init | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/sbtools/sb-init b/scripts/sbtools/sb-init index d44cd4b3..5073afe2 100755 --- a/scripts/sbtools/sb-init +++ b/scripts/sbtools/sb-init @@ -22,7 +22,11 @@ tput bold; echo "$(tput setaf 2)Installing required OS dependencies. This may ta sudo $DIR/aptfile apt-requirements # Update system pip3 to latest version -sudo python3 -m pip install --upgrade pip --break-system-packages +if $(dpkg --compare-versions $(py_ver) "gt" "3.10.0"); then + sudo python3 -m pip install --upgrade pip --break-system-packages +else + sudo python3 -m pip install --upgrade pip +fi # Check python version, if it's greater than 3.9 (bullseye version), we will create a venv, if not, we will follow normal install but really should push # users to using a venv From c9b626c3e0fc6fb708466e51e793b7555312752c Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 23 Feb 2024 15:11:35 -0600 Subject: [PATCH 29/37] Add exits in install script after sb-init or sb-upgrade is run --- scripts/install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install.sh b/scripts/install.sh index 85ff5f2f..54767f05 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -60,10 +60,12 @@ calc_wt_size() { do_install() { scripts/sbtools/sb-init + exit 0 } do_upgrade() { scripts/sbtools/sb-upgrade + exit 0 } do_help() { From 6895931d1c8b15fe2439d126b0b93e8e6df84748 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 23 Feb 2024 16:45:43 -0600 Subject: [PATCH 30/37] Fix some typos in sb-upgrade --- scripts/sbtools/sb-upgrade | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/sbtools/sb-upgrade b/scripts/sbtools/sb-upgrade index e2913d97..b9cf3c60 100755 --- a/scripts/sbtools/sb-upgrade +++ b/scripts/sbtools/sb-upgrade @@ -67,11 +67,7 @@ git config rebase.autoStash true local ret=0 # Update nhl-led-scoreboard -<<<<<<< HEAD -printf "${GREEN}%s${RESET}\n" "Checking to see if we can updtae NHL LED Scoreboard" -======= -printf "${GREEN}%s${RESET}\n" "Updating NHL LED Scoreboard" ->>>>>>> 1e768c9411aad7485f16f00cf86136be533fd9bd +printf "${GREEN}%s${RESET}\n" "Seeing if we can update the NHL LED Scoreboard" last_commit=$(git rev-parse HEAD) if git pull --rebase --stat origin master; then # Check if it was really updated or not From 8124874c6d5ddfda35d655530312e9b029cdb0f7 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 23 Feb 2024 17:16:41 -0600 Subject: [PATCH 31/37] Update requirements.txt Remove RPi.GPIO as we don't use it --- requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 63d52489..ddf055d5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -env-canada>=0.6.1 ephem fastjsonschema>=2.14.4 geocoder>=1.38.1 @@ -8,7 +7,6 @@ noaa-sdk>=0.1.18 pyowm>=3.0.0 python-tsl2591==0.2.0 regex>=2020.4.4 -RPi.GPIO>=0.7.1 APScheduler==3.10.4 lastversion>=1.1.6 nameparser>=1.0.6 @@ -19,3 +17,4 @@ cairosvg tzlocal rich diskcache +env-canada>=0.6.1 From 9bacef4836120c305f8493bd1f297fda7ae58599 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 23 Feb 2024 17:30:28 -0600 Subject: [PATCH 32/37] Make sure we don't keep adding to cmdline.txt --- scripts/sbtools/sb-init | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/sbtools/sb-init b/scripts/sbtools/sb-init index 5073afe2..d67dee0e 100755 --- a/scripts/sbtools/sb-init +++ b/scripts/sbtools/sb-init @@ -130,7 +130,10 @@ sudo modprobe -r snd_bcm2835 # Rebuild module dependacy sudo depmod -a -sudo sed -i 's/$/ isolcpus=3/' /boot/cmdline.txt +if ! grep -q isolcpus /boot/cmdline.txt; then + tput bold; echo "$(tput setaf 4)Optimizing pi for python (isolating cpus)...$(tput setaf 9)" ; tput sgr0 + sudo sed -i 's/$/ isolcpus=3/' /boot/cmdline.txt +fi git reset --hard git fetch origin --prune From 292dec6bda4df4bd0bdd0c5c7834baf47aae47eb Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 23 Feb 2024 17:31:28 -0600 Subject: [PATCH 33/37] Delete scripts/sbtools/config_novenv.sh --- scripts/sbtools/config_novenv.sh | 49 -------------------------------- 1 file changed, 49 deletions(-) delete mode 100755 scripts/sbtools/config_novenv.sh diff --git a/scripts/sbtools/config_novenv.sh b/scripts/sbtools/config_novenv.sh deleted file mode 100755 index 1b9c62b9..00000000 --- a/scripts/sbtools/config_novenv.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -# Make script work regardless of where it is run from -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -cd "${DIR}/.." || exit - -if (whiptail --title "New install?" --yesno "Is this a new install?" 8 78); then - tput bold; echo "$(tput setaf 2)Installing required OS dependencies. This may take some time (10-20 minutes-ish)...$(tput setaf 9)" ; tput sgr0 -else - whiptail --msgbox "To upgrade, run scripts/sbtools/sb-upgrade instead..." 25 80 - tput bold; echo "$(tput setaf 2)To upgrade, run scripts/sbtools/sb-upgrade instead...$(tput setaf 9)" ; tput sgr0 - exit -fi - -echo "$(tput setaf 6)Installing required dependencies. This may take some time (10-20 minutes-ish)...$(tput setaf 9)" -#Install all apt requirements using aptfile -sudo scripts/aptfile apt-requirements - -#Install all pip3 requirements using the requirements.txt filer -sudo pip3 install -r requirements.txt - -# Pull submodule and ignore changes from script -git submodule update --init --recursive -git config submodule.matrix.ignore all - -echo "$(tput setaf 4)Running rgbmatrix installation...$(tput setaf 9)" - -# Recompile the cpp files to build library with newest cython. See https://github.com/hzeller/rpi-rgb-led-matrix/issues/1298 - -cd submodules/matrix/bindings/python/rgbmatrix/ || exit - -# The following lines are no longer necessary -# python3 -m pip install --no-cache-dir cython -# python3 -m cython -2 --cplus *.pyx - -cd ../../../ || exit - -make build-python PYTHON="$(command -v python3)" -sudo make install-python PYTHON="$(command -v python3)" - -cd ../../../ || exit - -git reset --hard -git fetch origin --prune -git pull - -make -echo "If you didn't see any errors above, everything should be installed!" -echo "$(tput bold)$(tput smso)$(tput setaf 2)Installation complete!$(tput sgr0) Play around with the examples in nhl-led-scoreboard/submodules/matrix/bindings/python/samples to make sure your matrix is working." From 4edf25bf8d8e2692612a0cd04d23503ead3a2f9d Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 23 Feb 2024 18:05:50 -0600 Subject: [PATCH 34/37] Add in fake user email and user name for git config so sb-upgrade can work --- scripts/sbtools/sb-init | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/sbtools/sb-init b/scripts/sbtools/sb-init index d67dee0e..8d27a65e 100755 --- a/scripts/sbtools/sb-init +++ b/scripts/sbtools/sb-init @@ -135,6 +135,9 @@ if ! grep -q isolcpus /boot/cmdline.txt; then sudo sed -i 's/$/ isolcpus=3/' /boot/cmdline.txt fi +git config --global user.email "first@example.com" +git config --global user.name "User Name" + git reset --hard git fetch origin --prune git pull From 6a9aa44c1d91b3cc92af9494182de559b23286db Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 23 Feb 2024 18:16:51 -0600 Subject: [PATCH 35/37] Update sb-upgrade --- scripts/sbtools/sb-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sbtools/sb-upgrade b/scripts/sbtools/sb-upgrade index b9cf3c60..b425ed52 100755 --- a/scripts/sbtools/sb-upgrade +++ b/scripts/sbtools/sb-upgrade @@ -123,7 +123,7 @@ if git pull --rebase --stat origin master; then # Update the status of the download so image user is not asked to upgrade on login again # comment the line below if running from the repo #/home/pi/sbtools/checkUpdate.sh > /home/pi/.nhlledportal/status - printf "${BLUE}%s${RESET}\n" "$message" + printf "${YELLOW}%s${RESET}\n" "$message" else ret=$? printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?' From c7fe97df2ec39148b90825e90154bdee18c38a16 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Fri, 23 Feb 2024 22:10:10 -0600 Subject: [PATCH 36/37] Update sb-init Add pull rebase strategy into sb-init --- scripts/sbtools/sb-init | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/sbtools/sb-init b/scripts/sbtools/sb-init index 8d27a65e..c5bc51c5 100755 --- a/scripts/sbtools/sb-init +++ b/scripts/sbtools/sb-init @@ -137,6 +137,7 @@ fi git config --global user.email "first@example.com" git config --global user.name "User Name" +git config pull.rebase false git reset --hard git fetch origin --prune From 881e21a2d1bbbe37b988937381f729bf88fc8759 Mon Sep 17 00:00:00 2001 From: Sean Ostermann Date: Sat, 24 Feb 2024 17:39:07 -0600 Subject: [PATCH 37/37] Update sb-init --- scripts/sbtools/sb-init | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/sbtools/sb-init b/scripts/sbtools/sb-init index c5bc51c5..8ac9f2ff 100755 --- a/scripts/sbtools/sb-init +++ b/scripts/sbtools/sb-init @@ -71,7 +71,7 @@ TEXT0 #This will install into the virtual environment tput bold; echo "$(tput setaf 2)Installing scoreboard python requirements in virtual environment...$(tput setaf 9)" ; tput sgr0 - pip3 install -r requirements.txt + pip3 install -U -r requirements.txt tput bold; echo "$(tput setaf 4)...................................................$(tput setaf 9)" ; tput sgr0 tput bold; echo "$(tput setaf 4)TAKE NOTE OF NEXT LINES...$(tput setaf 9)" ; tput sgr0 @@ -81,7 +81,7 @@ TEXT0 tput bold; echo "$(tput setaf 1)sudo $HOME/nhlsb-venv/bin/python3 $(tput setaf 9)" ; tput sgr0 tput bold; echo "$(tput setaf 4)...................................................$(tput setaf 9)" ; tput sgr0 else - sudo pip3 install -r requirements.txt + sudo pip3 install -U -r requirements.txt fi # Pull submodule and ignore changes from script git submodule update --init --recursive