From 3174aff2bc60d5d717561ba8b558b5c39b1bdee5 Mon Sep 17 00:00:00 2001 From: s3lph Date: Fri, 31 May 2024 21:14:23 +0200 Subject: [PATCH] chore: update client.py for python 3.12 utcnow deprecation --- client.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/client.py b/client.py index eb26d47..32f411f 100755 --- a/client.py +++ b/client.py @@ -3,7 +3,8 @@ import abc import time from getpass import getpass -from datetime import datetime +from datetime import datetime, timezone +import time import imaplib import poplib import smtplib @@ -438,7 +439,7 @@ def _create_submission_request(address: str, submission_address: str, fingerprin mail['Subject'] = 'WKS submission request' mail['To'] = submission_address mail['From'] = address - mail['Date'] = format_datetime(datetime.utcnow()) + mail['Date'] = format_datetime(datetime.now(timezone.utc)) return mail @@ -467,7 +468,7 @@ def _create_confirmation_response(address: str, submission: str, nonce: str, fp: mail['Subject'] = 'WKS confirmation response' mail['To'] = submission mail['From'] = address - mail['Date'] = format_datetime(datetime.utcnow()) + mail['Date'] = format_datetime(datetime.now(timezone.utc)) return mail @@ -624,14 +625,14 @@ def main(): print('Aborted') exit(1) with incoming_server: - now = datetime.utcnow() + now = time.monotonic() done = False request = _create_submission_request(ad, sa, fp, rfprs) print('Sending submission request') with outgoing_server: outgoing_server.send_message(request) print('Awaiting response') - while not done and (datetime.utcnow() - now).total_seconds() < 300: + while not done and time.monotonic() - now < 300: time.sleep(5) for message in incoming_server.get_new_messages(): done = handle_incoming_message(ad, fp, message, outgoing_server)