Skip to content

Commit

Permalink
Update deprecated method in expire_accounts.py (#10173)
Browse files Browse the repository at this point in the history
* Update deprecated method

---------

Co-authored-by: Mek <michael.karpeles@gmail.com>
  • Loading branch information
jimchamp and mekarpeles authored Dec 22, 2024
1 parent c32743e commit 43a3662
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/expire_accounts.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from datetime import datetime
from datetime import UTC, datetime

import web


def delete_old_links():
for doc in web.ctx.site.store.values(type="account-link"):
expiry_date = datetime.strptime(doc["expires_on"], "%Y-%m-%dT%H:%M:%S.%f")
now = datetime.utcnow()
# Make expiry_date timezone-aware:
expiry_date = expiry_date.replace(tzinfo=UTC)
now = datetime.now(UTC)
key = doc["_key"]
if expiry_date > now:
print("Deleting link %s" % (key))
Expand Down

0 comments on commit 43a3662

Please sign in to comment.