It would help if we knew what the problem was. "No longer works" doesn't tell us much.
On Wed, Jan 6, 2021 at 10:00 AM Arend <arendheng...@gmail.com> wrote: > In addition to the previous: the get_scalar function still seems to be > working but the get_series function no longer works. > > Op woensdag 6 januari 2021 om 18:33:12 UTC+1 schreef Arend: > >> Everything worked fine until I did the upgrade. >> >> I guess something has changed in the way XTypes are handled? >> >> *This is the code I use in extensions.py:* >> >> # >> # Copyright (c) 2009-2015 Tom Keffer <tke...@gmail.com> >> # >> # See the file LICENSE.txt for your full rights. >> # >> >> """User extensions module >> >> This module is imported from the main executable, so anything put here >> will be >> executed before anything else happens. This makes it a good place to put >> user >> extensions. >> """ >> >> import locale >> # This will use the locale specified by the environment variable 'LANG' >> # Other options are possible. See: >> # http://docs.python.org/2/library/locale.html#locale.setlocale >> locale.setlocale(locale.LC_ALL, '') >> >> import user.lowest_temperature >> import weewx.xtypes >> >> weewx.xtypes.xtypes.append(user.lowest_temperature.LowestTemperature()) >> >> >> *This is the code in lowest_temperature.py:* >> >> import weewx.units >> import weewx.xtypes >> from weewx.units import ValueTuple >> >> class LowestTemperature(weewx.xtypes.XType): >> >> def get_scalar(self, obs_type, record, dbmanager): >> """Determine which sensor has lowest temperature.""" >> if obs_type != 'lowTemperature': >> raise weewx.UnknownType >> try: >> record_us = weewx.units.to_US(record) >> if record_us['outTemp'] == None or record_us['extraTemp1'] == None: >> # if record_us['outTemp'] < 100 or record_us['extraTemp1'] < 100: >> raise TypeError("Temperature(s) equal to None") >> if record_us['outTemp'] <= record_us['extraTemp1']: >> lowTemperature = record_us['outTemp'] >> else: >> lowTemperature = record_us['extraTemp1'] >> return ValueTuple(lowTemperature, "degree_F", "group_temperature") >> except KeyError: >> # Don't have everything we need. Raise an exception. >> raise weewx.CannotCalculate(obs_type) >> >> def get_series(self, obs_type, timespan, db_manager, >> aggregate_type=None, aggregate_interval=None): >> if obs_type != 'lowTemperature': >> raise weewx.UnknownType >> start_vec = list() >> stop_vec = list() >> data_vec = list() >> if aggregate_type: >> raise weewx.UnknownAggregation(aggregate_type) >> for record in db_manager.genSql("SELECT `dateTime`, `interval`, >> `usUnits`, `outTemp`, `extraTemp1` FROM `archive` WHERE `dateTime` > >> %(start)s AND `dateTime` <= %(stop)s;" % {'start': timespan[0], 'stop': >> timespan[1]}): >> if (record[2] != 1): >> raise weewx.CannotCalculate("units are not US") >> if record[3] == None or record[4] == None: >> # if record[3] < 100 or record[4] < 100: >> raise TypeError("Temperature(s) equal to None") >> start_vec.append(record[0] - record[1] * 60) >> stop_vec.append(record[0]) >> if record[3] <= record[4]: >> data_vec.append(record[3]) >> else: >> data_vec.append(record[4]) >> return (ValueTuple(start_vec, 'unix_epoch', 'group_time'), >> ValueTuple(stop_vec, 'unix_epoch', 'group_time'), ValueTuple(data_vec, >> "degree_F", "group_temperature")) >> >> Do I need to rewrite all code? >> >> -- > You received this message because you are subscribed to the Google Groups > "weewx-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to weewx-user+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/weewx-user/5ac947ed-240d-428b-8a69-c0186359d97cn%40googlegroups.com > <https://groups.google.com/d/msgid/weewx-user/5ac947ed-240d-428b-8a69-c0186359d97cn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAPq0zEDKVqxjVdizyOr5nMvYPFxY5SGUq0T9vN26WkLa0zaUaA%40mail.gmail.com.