v.0.11.2 added beautyful soup bs4
This commit is contained in:
@@ -21,14 +21,14 @@ async def weather_check_task(weather_checker: Weather_Checker):
|
||||
|
||||
while True:
|
||||
for city in CITY_LIST:
|
||||
weather_checker.check(city=city, lang="de", test_mode=True)
|
||||
weather_checker.check(city=city, lang="de", test_mode=False)
|
||||
print(f"Checked {city}")
|
||||
await asyncio.sleep(3 * 60)
|
||||
|
||||
|
||||
async def api_server_check_task(api_server_checker: API_Server_Checker):
|
||||
while True:
|
||||
rnd_item_id: int = random.randrange(4)
|
||||
rnd_item_id: int = random.randrange(5)
|
||||
|
||||
api_server_checker.check(rnd_item_id)
|
||||
await asyncio.sleep(10)
|
||||
@@ -36,13 +36,9 @@ async def api_server_check_task(api_server_checker: API_Server_Checker):
|
||||
|
||||
async def print_time_task() -> None:
|
||||
bottom_ypos = display.MATRIX_HEIGHT - display.font_height
|
||||
simpleCnt: SimpleCounter = SimpleCounter()
|
||||
digitalClock: DigitalClock = DigitalClock(display, 0, bottom_ypos)
|
||||
while True:
|
||||
dt1: str = get_datetime_string()
|
||||
simpleCnt += 1
|
||||
print(f"print_time_task running... {simpleCnt.value % 16} {dt1}")
|
||||
|
||||
while True:
|
||||
await digitalClock.tick()
|
||||
await asyncio.sleep(2)
|
||||
|
||||
|
||||
@@ -15,16 +15,20 @@ class API_Server_Checker:
|
||||
else f"{BASE_API_URL}/items/{item_id}"
|
||||
)
|
||||
print(f"query: {items_url}")
|
||||
r = urequests.get(items_url)
|
||||
print("Status-Code:", r.status_code)
|
||||
json_resp = r.json()
|
||||
|
||||
if r.status_code == 200:
|
||||
print("json_resp:", json_resp)
|
||||
else:
|
||||
print("api-server error:", json_resp["error"]["message"])
|
||||
try:
|
||||
r = urequests.get(items_url)
|
||||
print("Status-Code:", r.status_code)
|
||||
json_resp = r.json()
|
||||
|
||||
r.close()
|
||||
if r.status_code == 200:
|
||||
print("json_resp:", json_resp)
|
||||
else:
|
||||
print("api-server error:", json_resp["error"]["message"])
|
||||
except OSError as e:
|
||||
print(f"api-server call failed: {e}")
|
||||
finally:
|
||||
r.close()
|
||||
|
||||
def check(self, item_id: int):
|
||||
self._get_items(item_id)
|
||||
|
||||
@@ -123,19 +123,16 @@ class Weather_Checker:
|
||||
color=colors.RAINBOW[2],
|
||||
)
|
||||
ypos += self.display.font_height + 1
|
||||
|
||||
updated_time_str: str = str(w_resp.weather.current.last_updated)[-5:]
|
||||
local_time_str: str = str(w_resp.weather.location.localtime)[-5:]
|
||||
|
||||
self.display.write_text(
|
||||
f"upd:{str(w_resp.weather.current.last_updated)[-5:]}",
|
||||
f"{local_time_str} {updated_time_str}",
|
||||
0,
|
||||
ypos,
|
||||
color=colors.RAINBOW[3],
|
||||
)
|
||||
ypos += self.display.font_height + 1
|
||||
self.display.write_text(
|
||||
f"cur:{str(w_resp.weather.location.localtime)[-5:]}",
|
||||
0,
|
||||
ypos,
|
||||
color=colors.RAINBOW[4],
|
||||
)
|
||||
else:
|
||||
ypos = 0
|
||||
self.display.write_text(
|
||||
|
||||
@@ -32,9 +32,6 @@ class DigitalClock:
|
||||
fresh_part: str = time_str[mismatch_pos:]
|
||||
part_to_clear: str = self.stored_time_str[mismatch_pos:]
|
||||
|
||||
textwidth: int = self._text_width(self.stored_time_str)
|
||||
print(f"{self.stored_time_str}: #{textwidth}")
|
||||
|
||||
textwidth_untouched_part: int = self._text_width(untouched_part)
|
||||
clear_x_start_pos: int = self.xpos + textwidth_untouched_part + 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user