Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-py3status for 
openSUSE:Factory checked in at 2024-06-14 19:03:07
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-py3status (Old)
 and      /work/SRC/openSUSE:Factory/.python-py3status.new.19518 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-py3status"

Fri Jun 14 19:03:07 2024 rev:15 rq:1180935 version:3.58

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-py3status/python-py3status.changes        
2024-06-03 17:42:07.208073154 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-py3status.new.19518/python-py3status.changes 
    2024-06-14 19:07:45.519859399 +0200
@@ -1,0 +2,7 @@
+Wed Jun  5 10:11:02 UTC 2024 - Dawid Adam <nys...@gmail.com>
+
+- update to 3.58:
+  * conky module: skip invalid conky errors
+  * weather_owm module: switch to 3.0 API endpoint as 2.5 is deprecated
+
+-------------------------------------------------------------------

Old:
----
  py3status-3.57.tar.gz

New:
----
  py3status-3.58.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-py3status.spec ++++++
--- /var/tmp/diff_new_pack.Tsxk79/_old  2024-06-14 19:07:46.011876889 +0200
+++ /var/tmp/diff_new_pack.Tsxk79/_new  2024-06-14 19:07:46.015877031 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-py3status
 #
-# Copyright (c) 2023 SUSE LLC
+# Copyright (c) 2024 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,12 +18,12 @@
 
 %define skip_python2 1
 Name:           python-py3status
-Version:        3.57
+Version:        3.58
 Release:        0
 Summary:        Python extensible i3status wrapper
 License:        BSD-3-Clause
 URL:            https://github.com/ultrabug/py3status
-Source:         
https://github.com/ultrabug/py3status/archive/3.57.tar.gz#/py3status-3.57.tar.gz
+Source:         
https://github.com/ultrabug/py3status/archive/%{version}.tar.gz#/py3status-%{version}.tar.gz
 BuildRequires:  %{python_module hatchling}
 BuildRequires:  %{python_module pip}
 BuildRequires:  %{python_module pytest}
@@ -65,6 +65,7 @@
 %pyproject_install
 %python_clone -a %{buildroot}%{_bindir}/py3status
 %python_clone -a %{buildroot}%{_bindir}/py3-cmd
+%python_expand chmod -x %{buildroot}%{$python_sitelib}/py3status/__init__.py
 %python_expand %fdupes %{buildroot}%{$python_sitelib}
 
 %check

++++++ py3status-3.57.tar.gz -> py3status-3.58.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py3status-3.57/CHANGELOG new/py3status-3.58/CHANGELOG
--- old/py3status-3.57/CHANGELOG        2024-03-26 16:09:58.000000000 +0100
+++ new/py3status-3.58/CHANGELOG        2024-05-31 12:17:15.000000000 +0200
@@ -1,3 +1,7 @@
+version 3.58 (2024-05-31)
+* conky module: skip invalid conky errors (#2248), by lasers
+* weather_owm module: switch to 3.0 API endpoint as 2.5 is deprecated (#2249)
+
 version 3.57 (2024-03-26)
 * docs: explain how to serve mkdocs locally (#2239), by Lujeni
 * add CodeQL workflow for GitHub code scanning (#2159), by lgtm-com[bot]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py3status-3.57/py3status/modules/conky.py 
new/py3status-3.58/py3status/modules/conky.py
--- old/py3status-3.57/py3status/modules/conky.py       2024-03-26 
16:09:58.000000000 +0100
+++ new/py3status-3.58/py3status/modules/conky.py       2024-05-31 
12:17:15.000000000 +0200
@@ -363,7 +363,7 @@
         self.config.update({"out_to_x": False, "out_to_console": True})
         self.separator = "|SEPARATOR|"  # must be upper
 
-        # make an output.
+        # make an output
         config = dumps(self.config, separators=(",", "=")).replace('"', "")
         text = self.separator.join([f"${{{x}}}" for x in conky_placeholders])
         tmp = f"conky.config = {config}\nconky.text = [[{text}]]"
@@ -374,6 +374,12 @@
         self.tmpfile.close()
         self.conky_command = f"conky -c {self.tmpfile.name}".split()
 
+        # skip invalid conky errors
+        self.invalid_conky_errors = [
+            "conky: invalid setting of type 'table'",
+            "conky: FOUND:",
+        ]
+
         # thread
         self.line = ""
         self.error = None
@@ -393,8 +399,7 @@
             while True:
                 line = self.process.stdout.readline().decode()
                 if self.process.poll() is not None or "conky:" in line:
-                    # workaround to 
https://github.com/brndnmtthws/conky/issues/1479
-                    if "conky: invalid setting of type 'table'" in line:
+                    if any(x in line for x in self.invalid_conky_errors):
                         continue
                     raise Exception(line)
                 if self.line != line:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py3status-3.57/py3status/modules/weather_owm.py 
new/py3status-3.58/py3status/modules/weather_owm.py
--- old/py3status-3.57/py3status/modules/weather_owm.py 2024-03-26 
16:09:58.000000000 +0100
+++ new/py3status-3.58/py3status/modules/weather_owm.py 2024-05-31 
12:17:15.000000000 +0200
@@ -8,11 +8,11 @@
 
 This module uses OpenWeatherMap API (https://openweathermap.org).
 
-setting `location` or `city` allows you to specify the location for the weather
-you want displaying.
+Requires a 3.0 API key for OpenWeatherMap (OWM) with a subscription which this
+module will try as hard as it can to stay under the free tier limit.
 
-Requires an API key for OpenWeatherMap (OWM), but the free tier allows you
-enough requests/sec to get accurate weather even up to the minute.
+Setting `location` or `city` allows you to specify the location for the weather
+you want displaying.
 
 I would highly suggest you install an additional font, such as the incredible
 (and free!) Weather Icons font (https://erikflowers.github.io/weather-icons),
@@ -261,11 +261,12 @@
 """
 
 import datetime
+import json
 
 # API information
 OWM_CURR_ENDPOINT = "https://api.openweathermap.org/data/2.5/weather?";
 OWM_FUTURE_ENDPOINT = "https://api.openweathermap.org/data/2.5/forecast?";
-OWM_ONECALL_ENDPOINT = "https://api.openweathermap.org/data/2.5/onecall?";
+OWM_ONECALL_ENDPOINT = 
"https://api.openweathermap.org/data/3.0/onecall?exclude=alerts,minutely";
 IP_ENDPOINT = "http://geo.ultrabug.fr";
 
 # Paths of information to extract from JSON
@@ -448,6 +449,18 @@
         # Generate our icon array
         self.icons = self._get_icons()
 
+        # Implement safe-to-reload rate limit
+        cached_day = datetime.datetime.now(datetime.UTC).strftime("%Y%m%d")
+        self.cached_hits = json.loads(
+            self.py3.storage_get("cached_hits") or json.dumps({cached_day: 0})
+        )
+        self.cached_onecall_response = 
self.py3.storage_get("cached_onecall_response")
+
+        # We want to make sure users to not exceed the request limit
+        # to 3.0 API and get billed while taking into account that
+        # OWM does refresh its API data every 10min anyway.
+        self.cache_timeout = max(600, self.cache_timeout)
+
         # Verify the units configuration
         if self.unit_rain.lower() not in RAIN_UNITS:
             raise Exception("unit_rain is not recognized")
@@ -817,6 +830,9 @@
         return self.py3.safe_format(self.format, today)
 
     def weather_owm(self):
+        # Prepare rate limit cache
+        cached_day = datetime.datetime.now(datetime.UTC).strftime("%Y%m%d")
+        cached_hits = self.cached_hits.get(cached_day, 0)
         # Get weather information
         loc_tz_info = self._get_loc_tz_info()
         text = ""
@@ -840,9 +856,19 @@
             except Exception:
                 raise Exception("no latitude/longitude found for your config")
 
-            # onecall = forecasts
-            onecall_api_params = {"lat": lat, "lon": lon}
-            onecall = self._get_onecall(onecall_api_params)
+            # onecall = forecasts rate limited
+            if cached_hits < 999:
+                onecall_api_params = {"lat": lat, "lon": lon}
+                onecall = self._get_onecall(onecall_api_params)
+                # update and store caches
+                self.cached_onecall_response = onecall
+                self.cached_hits[cached_day] = cached_hits + 1
+                self.py3.storage_set("cached_onecall_response", onecall)
+                self.py3.storage_set(
+                    "cached_hits", json.dumps({cached_day: 
self.cached_hits[cached_day]})
+                )
+            else:
+                onecall = self.cached_onecall_response
             onecall_daily = onecall["daily"]
 
             fcsts_days = self.forecast_days + 1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py3status-3.57/py3status/version.py 
new/py3status-3.58/py3status/version.py
--- old/py3status-3.57/py3status/version.py     2024-03-26 16:09:58.000000000 
+0100
+++ new/py3status-3.58/py3status/version.py     2024-05-31 12:17:15.000000000 
+0200
@@ -1 +1 @@
-version = "3.57"
+version = "3.58"

Reply via email to