Skip to content

Commit

Permalink
dhcp: Fix depracted utcfromtimestamp usage
Browse files Browse the repository at this point in the history
Deprecated as per https://docs.python.org/3/library/datetime.html#datetime.datetime.utcfromtimestamp
Fixes: TypeError: can't subtract offset-naive and offset-aware datetimes
  • Loading branch information
Erkki Eilonen committed Dec 26, 2024
1 parent 77d5b09 commit bc08e72
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/op_mode/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def _get_raw_server_leases(family='inet', pool=None, sorted=None, state=[], orig
lifetime = lease['valid-lft']
expiry = (lease['cltt'] + lifetime)

lease['start_timestamp'] = datetime.utcfromtimestamp(expiry - lifetime)
lease['expire_timestamp'] = datetime.utcfromtimestamp(expiry) if expiry else None
lease['start_timestamp'] = datetime.fromtimestamp(expiry - lifetime, timezone.utc)
lease['expire_timestamp'] = datetime.fromtimestamp(expiry, timezone.utc) if expiry else None

data_lease = {}
data_lease['ip'] = lease['ip-address']
Expand Down

0 comments on commit bc08e72

Please sign in to comment.