diff options
| author | Jacob McDonnell <jacob@simplelittledream.com> | 2022-10-31 15:17:09 -0400 |
|---|---|---|
| committer | Jacob McDonnell <jacob@simplelittledream.com> | 2022-10-31 15:17:09 -0400 |
| commit | b2e6cdde266260a525ef80147dacbcd2ada3a985 (patch) | |
| tree | c1c40d6fbba8d53889040bffb22e46c58b51b4c5 | |
| parent | 4681ebe60b5020c63c58034ad3072c0c5e3ca940 (diff) | |
Better organization of codeporting-to-pico
| -rw-r--r-- | __pycache__/Adafruit_Thermal.cpython-310.pyc | bin | 0 -> 15299 bytes | |||
| -rw-r--r-- | __pycache__/cal.cpython-310.pyc | bin | 0 -> 1333 bytes | |||
| -rw-r--r-- | __pycache__/ipqr.cpython-310.pyc | bin | 0 -> 630 bytes | |||
| -rw-r--r-- | __pycache__/natDay.cpython-310.pyc | bin | 0 -> 666 bytes | |||
| -rw-r--r-- | __pycache__/news.cpython-310.pyc | bin | 0 -> 851 bytes | |||
| -rw-r--r-- | __pycache__/quote.cpython-310.pyc | bin | 0 -> 603 bytes | |||
| -rw-r--r-- | __pycache__/settings.cpython-310.pyc | bin | 0 -> 557 bytes | |||
| -rw-r--r-- | __pycache__/weather.cpython-310.pyc | bin | 0 -> 1807 bytes | |||
| -rw-r--r-- | cal.py | 3 | ||||
| -rw-r--r-- | main.py | 6 | ||||
| -rw-r--r-- | news.py | 3 | ||||
| -rw-r--r-- | settings.py | 18 | ||||
| -rw-r--r-- | weather.py | 3 |
13 files changed, 20 insertions, 13 deletions
diff --git a/__pycache__/Adafruit_Thermal.cpython-310.pyc b/__pycache__/Adafruit_Thermal.cpython-310.pyc Binary files differnew file mode 100644 index 0000000..e5d720c --- /dev/null +++ b/__pycache__/Adafruit_Thermal.cpython-310.pyc diff --git a/__pycache__/cal.cpython-310.pyc b/__pycache__/cal.cpython-310.pyc Binary files differnew file mode 100644 index 0000000..14ff64d --- /dev/null +++ b/__pycache__/cal.cpython-310.pyc diff --git a/__pycache__/ipqr.cpython-310.pyc b/__pycache__/ipqr.cpython-310.pyc Binary files differnew file mode 100644 index 0000000..7a37ec8 --- /dev/null +++ b/__pycache__/ipqr.cpython-310.pyc diff --git a/__pycache__/natDay.cpython-310.pyc b/__pycache__/natDay.cpython-310.pyc Binary files differnew file mode 100644 index 0000000..cff9b88 --- /dev/null +++ b/__pycache__/natDay.cpython-310.pyc diff --git a/__pycache__/news.cpython-310.pyc b/__pycache__/news.cpython-310.pyc Binary files differnew file mode 100644 index 0000000..16bec00 --- /dev/null +++ b/__pycache__/news.cpython-310.pyc diff --git a/__pycache__/quote.cpython-310.pyc b/__pycache__/quote.cpython-310.pyc Binary files differnew file mode 100644 index 0000000..adcd0a8 --- /dev/null +++ b/__pycache__/quote.cpython-310.pyc diff --git a/__pycache__/settings.cpython-310.pyc b/__pycache__/settings.cpython-310.pyc Binary files differnew file mode 100644 index 0000000..78b5539 --- /dev/null +++ b/__pycache__/settings.cpython-310.pyc diff --git a/__pycache__/weather.cpython-310.pyc b/__pycache__/weather.cpython-310.pyc Binary files differnew file mode 100644 index 0000000..c9460a8 --- /dev/null +++ b/__pycache__/weather.cpython-310.pyc @@ -2,8 +2,9 @@ import icalendar import recurring_ical_events import urllib.request import datetime -from settings import calendars +from settings import getSettings +calendars = getSettings("calendars") today = datetime.date.today() output = [] @@ -4,13 +4,17 @@ from news import getHeadlines from quote import getQuote from weather import getHourlyForecast, getDetailedForecast import datetime -from settings import modules, general, lineWidth +from settings import getSettings from time import sleep from Adafruit_Thermal import * from textwrap import fill from ipqr import getQrCode +general = getSettings("general") +modules = getSettings("modules") + name = general["name"] +lineWidth = general["Line Width"] today = datetime.date.today().strftime("%A %m-%d-%Y") printer = Adafruit_Thermal("/dev/serial0", 19200, timeout=5) @@ -1,8 +1,9 @@ import requests import json from time import sleep -from settings import news +from settings import getSettings +news = getSettings("news") apiKey = news["apikey"] countryCode = news["country"] diff --git a/settings.py b/settings.py index c5ed5c7..e94dbe2 100644 --- a/settings.py +++ b/settings.py @@ -1,14 +1,14 @@ import json +from logging import exception -settingsJSON = open('settings.json') +def getSettings(settingSection): + try: + settingsJSON = open("settings.json", "r") + except FileNotFoundError: + exception("settings.json not found make sure it exists in this folder") -settings = json.load(settingsJSON) + settings = json.load(settingsJSON) + settingsJSON.close() -calendars = settings["calendars"] -weather = settings["weather"] -news = settings["news"] -modules = settings["modules"] -general = settings["general"] -lineWidth = settings["general"]["Line Width"] + return settings[settingSection] -settingsJSON.close() @@ -2,8 +2,9 @@ import requests import json from time import sleep from datetime import datetime -from settings import weather +from settings import getSettings +weather = getSettings("weather") gridX = weather["gridX"] gridY = weather["gridY"] wfo = weather["WFO"] |
