chore: update client.py for python 3.12 utcnow deprecation
All checks were successful
/ test (push) Successful in 1m2s
/ codestyle (push) Successful in 1m0s
/ easywksserver_gpgwksclient (push) Successful in 1m19s

This commit is contained in:
s3lph 2024-05-31 21:14:23 +02:00
parent d9fa1733a8
commit 3174aff2bc
Signed by: s3lph
GPG key ID: 0AA29A52FB33CFB5

View file

@ -3,7 +3,8 @@
import abc import abc
import time import time
from getpass import getpass from getpass import getpass
from datetime import datetime from datetime import datetime, timezone
import time
import imaplib import imaplib
import poplib import poplib
import smtplib import smtplib
@ -438,7 +439,7 @@ def _create_submission_request(address: str, submission_address: str, fingerprin
mail['Subject'] = 'WKS submission request' mail['Subject'] = 'WKS submission request'
mail['To'] = submission_address mail['To'] = submission_address
mail['From'] = address mail['From'] = address
mail['Date'] = format_datetime(datetime.utcnow()) mail['Date'] = format_datetime(datetime.now(timezone.utc))
return mail return mail
@ -467,7 +468,7 @@ def _create_confirmation_response(address: str, submission: str, nonce: str, fp:
mail['Subject'] = 'WKS confirmation response' mail['Subject'] = 'WKS confirmation response'
mail['To'] = submission mail['To'] = submission
mail['From'] = address mail['From'] = address
mail['Date'] = format_datetime(datetime.utcnow()) mail['Date'] = format_datetime(datetime.now(timezone.utc))
return mail return mail
@ -624,14 +625,14 @@ def main():
print('Aborted') print('Aborted')
exit(1) exit(1)
with incoming_server: with incoming_server:
now = datetime.utcnow() now = time.monotonic()
done = False done = False
request = _create_submission_request(ad, sa, fp, rfprs) request = _create_submission_request(ad, sa, fp, rfprs)
print('Sending submission request') print('Sending submission request')
with outgoing_server: with outgoing_server:
outgoing_server.send_message(request) outgoing_server.send_message(request)
print('Awaiting response') print('Awaiting response')
while not done and (datetime.utcnow() - now).total_seconds() < 300: while not done and time.monotonic() - now < 300:
time.sleep(5) time.sleep(5)
for message in incoming_server.get_new_messages(): for message in incoming_server.get_new_messages():
done = handle_incoming_message(ad, fp, message, outgoing_server) done = handle_incoming_message(ad, fp, message, outgoing_server)