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
|
||||
|
||||
import config
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import logging
|
||||
@@ -224,14 +226,15 @@ class AirSegment(DisplaySegment):
|
||||
self.temperature = measurement["value"]
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
segments = [
|
||||
config.configure_env()
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
segments = [
|
||||
ClockSegment(),
|
||||
WeatherSegment(),
|
||||
TrafficSegment(),
|
||||
AirSegment()
|
||||
]
|
||||
|
||||
for segment in segments:
|
||||
print(segment.get_data_text())
|
||||
print("---")
|
||||
for segment in segments:
|
||||
print(segment.get_data_text())
|
||||
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