From 802bcfac6a334f5c9653431d350f6c2ed0a3171e Mon Sep 17 00:00:00 2001 From: Death916 Date: Mon, 21 Apr 2025 05:41:21 -0700 Subject: [PATCH] weather showing --- .gitignore | 1 + deathclock/deathclock.py | 4 ++-- utils/weather.py | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 757c6b5..255057a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ __pycache__/ chromedriver *.pyc .pyc +*.jpg diff --git a/deathclock/deathclock.py b/deathclock/deathclock.py index 5909fc7..eedd2eb 100644 --- a/deathclock/deathclock.py +++ b/deathclock/deathclock.py @@ -29,9 +29,9 @@ def index() -> rx.Component: color="white", background_color="#6f42c1", ), - rx.box( + rx.card( rx.image( - src=Weather().get_weather_screenshot(), + src="/weather.jpg", # Use relative path to static asset alt="Weather", width="100%", height="auto", diff --git a/utils/weather.py b/utils/weather.py index 4700d9a..f1fa26b 100644 --- a/utils/weather.py +++ b/utils/weather.py @@ -7,8 +7,8 @@ class Weather: # Get the directory where this script (weather.py) is located self.script_dir = os.path.dirname(os.path.abspath(__file__)) - # Construct the absolute path to the 'assets' directory in the same directory as the script - self.assets_dir = os.path.join(self.script_dir, 'assets') + # Construct the absolute path to the 'assets' directory in the project root + self.assets_dir = os.path.join(os.path.dirname(os.path.dirname(self.script_dir)), 'assets') # Ensure the assets directory exists if not os.path.exists(self.assets_dir): @@ -30,7 +30,7 @@ class Weather: try: # Create a timestamp for the filename timestamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S") - screenshot_filename = f"sacramento_weather_{timestamp}.png" + screenshot_filename = "weather.png" screenshot_path = os.path.join(self.assets_dir, screenshot_filename) # save to the proper location # Use curl to get the weather data from wttr.in and save it as a PNG. @@ -52,4 +52,4 @@ class Weather: return None except Exception as e: print(f"An unexpected error occurred: {e}") - return None \ No newline at end of file + return None