chore: update client.py for python 3.12 utcnow deprecation
This commit is contained in:
parent
d9fa1733a8
commit
3174aff2bc
1 changed files with 6 additions and 5 deletions
11
client.py
11
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)
|
||||
|
|
Loading…
Reference in a new issue