feat!: move config storage to python file
Should help with micropython in the future. Also fix indentation in main
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1 @@
|
|||||||
run.sh
|
config.py
|
||||||
|
|||||||
20
config.py
Executable file
20
config.py
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
def configure_env():
|
||||||
|
""" exports environment variables with configuration """
|
||||||
|
|
||||||
|
os.environ["LATITUDE"] = "…"
|
||||||
|
os.environ["LONGITUDE"] = "…"
|
||||||
|
|
||||||
|
os.environ["GOOGLE_API_KEY"] = "…"
|
||||||
|
os.environ["TRAFFIC_FROM"] = "…+FM"
|
||||||
|
#os.environ["TRAFFIC_FROM"] = f"${LATITUDE}-${LONGITUDE}"
|
||||||
|
os.environ["TRAFFIC_1_THROUGH"] = "…+4FP"
|
||||||
|
os.environ["TRAFFIC_2_THROUGH"] = "…+V9J"
|
||||||
|
os.environ["TRAFFIC_TO"] = "…+GX"
|
||||||
|
|
||||||
|
os.environ["AIRLY_API_KEY"] = "…"
|
||||||
|
|
||||||
|
os.environ["OPENWEATHERMAP_API_KEY"] = "…"
|
||||||
|
|
||||||
13
epaper.py
13
epaper.py
@@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import config
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
@@ -224,14 +226,15 @@ class AirSegment(DisplaySegment):
|
|||||||
self.temperature = measurement["value"]
|
self.temperature = measurement["value"]
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
config.configure_env()
|
||||||
segments = [
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
segments = [
|
||||||
ClockSegment(),
|
ClockSegment(),
|
||||||
WeatherSegment(),
|
WeatherSegment(),
|
||||||
TrafficSegment(),
|
TrafficSegment(),
|
||||||
AirSegment()
|
AirSegment()
|
||||||
]
|
]
|
||||||
|
|
||||||
for segment in segments:
|
for segment in segments:
|
||||||
print(segment.get_data_text())
|
print(segment.get_data_text())
|
||||||
print("---")
|
print("---")
|
||||||
|
|||||||
22
run.sh
22
run.sh
@@ -1,22 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
export LATITUDE=
|
|
||||||
export LONGITUDE=
|
|
||||||
|
|
||||||
export GOOGLE_API_KEY=…
|
|
||||||
#export TRAFFIC_FROM=
|
|
||||||
export TRAFFIC_FROM="${LATITUDE}-${LONGITUDE}"
|
|
||||||
export TRAFFIC_1_THROUGH=6JV5+4FP
|
|
||||||
export TRAFFIC_2_THROUGH=7JFQ+V8P
|
|
||||||
export TRAFFIC_TO=6JXP+GX
|
|
||||||
|
|
||||||
## Air information
|
|
||||||
|
|
||||||
export AIRLY_API_KEY=…
|
|
||||||
|
|
||||||
## Weather information
|
|
||||||
|
|
||||||
export FORECASTIO_API_KEY=
|
|
||||||
|
|
||||||
./epaper.py
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user