Closed sjthespian closed 3 years ago
The purple air extension needs a couple of tweaks to make it work with Python3:
> diff -ub /usr/share/weewx/user/purpleair.py.orig /usr/share/weewx/user/purpleair.py --- /usr/share/weewx/user/purpleair.py.orig 2020-05-28 15:01:43.429508266 -0700 +++ /usr/share/weewx/user/purpleair.py 2020-05-28 14:32:23.109570262 -0700 @@ -158,7 +158,7 @@ self.config_dict = config_dict.get('PurpleAirMonitor', {}) try: self.config_dict['hostname'] - except KeyError, e: + except KeyError as e: raise Exception("Data will not be posted: Missing option %s" % e) self.config_dict.setdefault('timeout', 10) # url fetch timeout @@ -204,7 +204,7 @@ if self.last_ts is not None: try: data = self.get_data(now, self.last_ts) - except Exception, e: + except Exception as e: # failure to fetch data, log and then return logerr(e) return @@ -259,7 +259,7 @@ def test_collector(hostname): session = requests.Session() while True: - print collect_data(session, hostname, 10) + print(collect_data(session, hostname, 10)) time.sleep(5) def test_service(hostname):
@sjthespian / @harpchad I believe this is fixed. I grabbed the pull request from @krbaker.
The purple air extension needs a couple of tweaks to make it work with Python3: