v.0.7.3 time_utils ntp access
This commit is contained in:
@@ -4,7 +4,7 @@ import json
|
||||
from app.classes import Weather, Location, CurrentCondition, WeatherResponse, ResponseStatus
|
||||
from app.display import NeoPixel_64x64
|
||||
import app.utils.colors as colors
|
||||
from app.utils import URLEncoder, http_message
|
||||
from app.utils import URLEncoder, http_message, get_datetime_string
|
||||
|
||||
API_KEY = '3545ce42d0ba436e8dc164532250410'
|
||||
ACTUAL_WEATHER_URL = 'http://api.weatherapi.com/v1/current.json?key={API_KEY}&q={city}&aqi=yes&lang={lang}'
|
||||
@@ -72,8 +72,12 @@ class Weather_Checker():
|
||||
|
||||
|
||||
def check(self, city:str, lang:str, test_mode: bool = False):
|
||||
bottom_ypos = self.display.MATRIX_HEIGHT - self.display.font_height
|
||||
|
||||
time_str: str = get_datetime_string('time')
|
||||
try:
|
||||
self.display.clear()
|
||||
self.display.write_text(time_str[:5], 0, bottom_ypos, color=colors.NEON_YELLOW)
|
||||
|
||||
city_encoded = URLEncoder.encode_utf8(city) # url_encode
|
||||
w_resp: WeatherResponse = self.actual_weather(city=city_encoded, lang=lang, test_mode=test_mode)
|
||||
@@ -103,9 +107,8 @@ class Weather_Checker():
|
||||
self.display.write_text(f'{w_resp.response_status.error_text}', 0, ypos, color=colors.RAINBOW[2])
|
||||
|
||||
# unten rechts in die Ecke
|
||||
ypos = self.display.MATRIX_HEIGHT - self.display.font_height - 1
|
||||
|
||||
self.display.write_text('done.', 38, ypos, color=colors.NEON_GREEN)
|
||||
self.display.write_text('done.', 39, bottom_ypos, color=colors.NEON_GREEN)
|
||||
except OSError as e:
|
||||
print(f'Error: connection closed - {e}')
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user