mirror of
https://github.com/weewx/weewx.git
synced 2026-04-17 16:16:56 -04:00
Port to Python 12.
Change deprecated datetime.utcfromtimestamp() to datetime.fromtimestamp().
This commit is contained in:
@@ -1093,7 +1093,7 @@ class FineOffsetUSB(weewx.drivers.AbstractDevice):
|
||||
"""
|
||||
records = self.get_records(since_ts)
|
||||
log.debug('found %d archive records' % len(records))
|
||||
epoch = datetime.datetime.utcfromtimestamp(0)
|
||||
epoch = datetime.datetime.fromtimestamp(0, datetime.timezone.utc)
|
||||
for r in records:
|
||||
delta = r['datetime'] - epoch
|
||||
# FIXME: deal with daylight saving corner case
|
||||
@@ -1292,7 +1292,7 @@ class FineOffsetUSB(weewx.drivers.AbstractDevice):
|
||||
if fixed_block['data_count'] is None:
|
||||
raise weewx.WeeWxIOError('invalid data_count in get_records')
|
||||
if since_ts:
|
||||
dt = datetime.datetime.utcfromtimestamp(since_ts)
|
||||
dt = datetime.datetime.fromtimestamp(since_ts, datetime.timezone.utc)
|
||||
dt += datetime.timedelta(seconds=fixed_block['read_period']*30)
|
||||
else:
|
||||
dt = datetime.datetime.min
|
||||
@@ -1516,7 +1516,8 @@ class FineOffsetUSB(weewx.drivers.AbstractDevice):
|
||||
while data_time > next_live + live_interval:
|
||||
log.debug('missed interval')
|
||||
next_live += live_interval
|
||||
result['idx'] = datetime.datetime.utcfromtimestamp(int(next_live))
|
||||
result['idx'] = datetime.datetime.fromtimestamp(int(next_live),
|
||||
datetime.timezone.utc)
|
||||
next_live += live_interval
|
||||
yield result, old_ptr, False
|
||||
old_data = new_data
|
||||
@@ -1554,7 +1555,8 @@ class FineOffsetUSB(weewx.drivers.AbstractDevice):
|
||||
next_log = None
|
||||
self._station_clock = None
|
||||
if next_log:
|
||||
result['idx'] = datetime.datetime.utcfromtimestamp(int(next_log))
|
||||
result['idx'] = datetime.datetime.fromtimestamp(int(next_log),
|
||||
datetime.timezone.utc)
|
||||
next_log += log_interval
|
||||
yield result, old_ptr, True
|
||||
if new_ptr != self.inc_ptr(old_ptr):
|
||||
|
||||
@@ -944,7 +944,8 @@ class AmbientThread(RESTThread):
|
||||
if _key == 'dateTime':
|
||||
# Convert from timestamp to string. The results will look something
|
||||
# like '2020-10-19%2021%3A43%3A18'
|
||||
_v = urllib.parse.quote(str(datetime.datetime.utcfromtimestamp(_v)))
|
||||
_s = str(datetime.datetime.fromtimestamp(_v, datetime.timezone.utc))
|
||||
_v = urllib.parse.quote(_s)
|
||||
# Format the value, and accumulate in _liststr:
|
||||
_liststr.append(self.formats[_key] % _v)
|
||||
# Now stick all the pieces together with an ampersand between them:
|
||||
@@ -1083,7 +1084,7 @@ class WOWThread(AmbientThread):
|
||||
if _v is not None:
|
||||
if _key == 'dateTime':
|
||||
_v = urllib.parse.quote_plus(
|
||||
datetime.datetime.utcfromtimestamp(_v).isoformat(' '))
|
||||
datetime.datetime.fromtimestamp(_v, datetime.timezone.utc).isoformat(' '))
|
||||
# Format the value, and accumulate in _liststr:
|
||||
_liststr.append(WOWThread._FORMATS[_key] % _v)
|
||||
# Now stick all the pieces together with an ampersand between them:
|
||||
|
||||
@@ -6,7 +6,7 @@ WeeWX change history
|
||||
Python 2.7 is no longer supported. You must have Python 3.7 (introduced
|
||||
May 2018) or greater.
|
||||
|
||||
WeeWX can now be installed using pip.
|
||||
WeeWX can now be installed using [pip](https://pip.pypa.io).
|
||||
|
||||
With pip installs, station data is stored in `~/weewx-data` by default,
|
||||
instead of `/home/weewx`. This allows pip installs to be done without
|
||||
@@ -16,16 +16,18 @@ The new utility [`weectl`](../utilities/weectl-about/) replaces `wee_database`,
|
||||
`wee_debug`, `wee_device`, `wee_extension`, and `wee_config`. Try `weectl
|
||||
--help` to see how to use it.
|
||||
|
||||
Documentation now uses [MkDocs](https://www.mkdocs.org/).
|
||||
|
||||
Package installs now use `systemd` instead of the old System V `/etc/init.d`.
|
||||
|
||||
Removed all references to the deprecated package `distutils`, which is due to
|
||||
be removed in Python v3.12.
|
||||
|
||||
Ported to Python v3.12.
|
||||
|
||||
Removed the utility `wunderfixer`. The Weather Underground seems to no longer
|
||||
allow posting past-dated records.
|
||||
|
||||
Documentation now uses [MkDocs](https://www.mkdocs.org/).
|
||||
|
||||
Logging handler `rotate` has been removed. Its need to access the privileged
|
||||
location `/var/log/` on start up would cause crashes, even if it was never
|
||||
used. Users can opt to add it back in by following the wiki on
|
||||
|
||||
Reference in New Issue
Block a user