@@ -315,14 +315,14 @@ def award_program_certificates(self, username): # lint-amnesty, pylint: disable
315
315
if str (programs_without_certificates [0 ]).lower () == "all" :
316
316
return
317
317
318
- LOGGER .info (f"Running task award_program_certificates for user { student } " )
318
+ LOGGER .info (f"Running task award_program_certificates for user { student . id } " )
319
319
try :
320
320
completed_programs = {}
321
321
for site in Site .objects .all ():
322
322
completed_programs .update (get_completed_programs (site , student ))
323
323
324
324
if not completed_programs :
325
- LOGGER .warning (f"Task award_program_certificates was called for user { student } with no completed programs" )
325
+ LOGGER .warning (f"Task award_program_certificates was called for user { student . id } with no completed programs" )
326
326
return
327
327
328
328
# determine which program certificates have been awarded to the user
@@ -331,7 +331,7 @@ def award_program_certificates(self, username): # lint-amnesty, pylint: disable
331
331
# program is part of the "programs without certificates" list in our site configuration
332
332
awarded_and_skipped_program_uuids = list (set (existing_program_uuids + list (programs_without_certificates )))
333
333
except Exception as exc :
334
- error_msg = f"Failed to determine program certificates to be awarded for user { student } : { exc } "
334
+ error_msg = f"Failed to determine program certificates to be awarded for user { student . id } : { exc } "
335
335
LOGGER .exception (error_msg )
336
336
raise MaxRetriesExceededError (
337
337
f"Failed to award a program certificate to user { student .id } . Reason: { error_msg } "
@@ -360,52 +360,52 @@ def award_program_certificates(self, username): # lint-amnesty, pylint: disable
360
360
for program_uuid in new_program_uuids :
361
361
try :
362
362
award_program_certificate (credentials_client , student , program_uuid )
363
- LOGGER .info (f"Awarded program certificate to user { student } in program { program_uuid } " )
363
+ LOGGER .info (f"Awarded program certificate to user { student . id } in program { program_uuid } " )
364
364
except HTTPError as exc :
365
365
if exc .response .status_code == 404 :
366
366
LOGGER .warning (
367
- f"Unable to award a program certificate to user { student } in program { program_uuid } . A "
367
+ f"Unable to award a program certificate to user { student . id } in program { program_uuid } . A "
368
368
f"certificate configuration for program { program_uuid } could not be found, the program might "
369
369
"not be configured correctly in Credentials"
370
370
)
371
371
elif exc .response .status_code == 429 :
372
372
# Let celery handle retry attempts and backoff
373
373
error_msg = (
374
- f"Rate limited. Attempting to award certificate to user { student } in program { program_uuid } ."
374
+ f"Rate limited. Attempting to award certificate to user { student . id } in program { program_uuid } ."
375
375
)
376
376
LOGGER .warning (error_msg )
377
377
raise MaxRetriesExceededError (
378
378
f"Failed to award a program certificate to user { student .id } . Reason: { error_msg } "
379
379
) from exc
380
380
else :
381
381
LOGGER .warning (
382
- f"Unable to award program certificate to user { student } in program { program_uuid } . The program "
383
- "might not be configured correctly in Credentials"
382
+ f"Unable to award program certificate to user { student . id } in program { program_uuid } . The "
383
+ "program might not be configured correctly in Credentials"
384
384
)
385
385
except Exception as exc : # pylint: disable=broad-except
386
386
# keep trying to award other certs, but let celery retry the whole task to fix any missing entries
387
387
LOGGER .exception (
388
- f"Failed to award program certificate to user { student } in program { program_uuid } : { exc } "
388
+ f"Failed to award program certificate to user { student . id } in program { program_uuid } : { exc } "
389
389
)
390
390
failed_program_certificate_award_attempts .append (program_uuid )
391
391
392
392
if failed_program_certificate_award_attempts :
393
393
# N.B. This logic assumes that this task is idempotent
394
- LOGGER .info (f"Retrying failed tasks to award program certificate(s) to user { student } " )
394
+ LOGGER .info (f"Retrying failed tasks to award program certificate(s) to user { student . id } " )
395
395
# The error message may change on each reattempt but will never be raised until the max number of retries
396
396
# have been exceeded. It is unlikely that this list will change by the time it reaches its maximimum number
397
397
# of attempts.
398
398
error_msg = (
399
- f"Failed to award program certificate(s) for user { student } in programs "
399
+ f"Failed to award program certificate(s) for user { student . id } in programs "
400
400
f"{ failed_program_certificate_award_attempts } "
401
401
)
402
402
raise MaxRetriesExceededError (
403
403
f"Failed to award a program certificate to user { student .id } . Reason: { error_msg } "
404
404
)
405
405
else :
406
- LOGGER .warning (f"User { student } is not eligible for any new program certificates" )
406
+ LOGGER .warning (f"User { student . id } is not eligible for any new program certificates" )
407
407
408
- LOGGER .info (f"Successfully completed the task award_program_certificates for user { student } " )
408
+ LOGGER .info (f"Successfully completed the task award_program_certificates for user { student . id } " )
409
409
410
410
411
411
# pylint: disable=W0613
@@ -504,7 +504,7 @@ def award_course_certificate(self, username, course_run_key):
504
504
)
505
505
return
506
506
507
- LOGGER .info (f"Running task award_course_certificate for user { user } " )
507
+ LOGGER .info (f"Running task award_course_certificate for user { user . id } " )
508
508
try :
509
509
course_key = CourseKey .from_string (course_run_key )
510
510
except InvalidKeyError as exc :
@@ -574,7 +574,7 @@ def award_course_certificate(self, username, course_run_key):
574
574
org = course_key .org ,
575
575
)
576
576
except Exception as exc :
577
- error_msg = f"Failed to post course certificate to be awarded for user { user } ."
577
+ error_msg = f"Failed to post course certificate to be awarded for user { user . id } ."
578
578
raise MaxRetriesExceededError (
579
579
f"Failed to award course certificate for user { user .id } for course { course_run_key } . Reason: { error_msg } "
580
580
) from exc
@@ -628,14 +628,14 @@ def revoke_program_certificates(self, username, course_key): # lint-amnesty, py
628
628
)
629
629
return
630
630
631
- LOGGER .info (f"Running task revoke_program_certificates for user { student } " )
631
+ LOGGER .info (f"Running task revoke_program_certificates for user { student . id } " )
632
632
try :
633
633
inverted_programs = get_inverted_programs (student )
634
634
course_specific_programs = inverted_programs .get (course_key )
635
635
if not course_specific_programs :
636
636
LOGGER .warning (
637
- f"Task revoke_program_certificates was called for user { student } and course run { course_key } with no "
638
- "engaged programs"
637
+ f"Task revoke_program_certificates was called for user { student . id } and course run { course_key } with "
638
+ "no engaged programs"
639
639
)
640
640
return
641
641
@@ -644,7 +644,7 @@ def revoke_program_certificates(self, username, course_key): # lint-amnesty, py
644
644
except Exception as exc :
645
645
error_msg = (
646
646
f"Failed to determine if any program certificates associated with course run { course_key } should be "
647
- f"revoked from user { student } "
647
+ f"revoked from user { student . id } "
648
648
)
649
649
LOGGER .exception (error_msg )
650
650
raise MaxRetriesExceededError (
@@ -668,17 +668,17 @@ def revoke_program_certificates(self, username, course_key): # lint-amnesty, py
668
668
for program_uuid in program_uuids_to_revoke :
669
669
try :
670
670
revoke_program_certificate (credentials_client , username , program_uuid )
671
- LOGGER .info (f"Revoked program certificate from user { student } in program { program_uuid } " )
671
+ LOGGER .info (f"Revoked program certificate from user { student . id } in program { program_uuid } " )
672
672
except HTTPError as exc :
673
673
if exc .response .status_code == 404 :
674
674
LOGGER .warning (
675
- f"Unable to revoke program certificate from user { student } in program { program_uuid } , a "
675
+ f"Unable to revoke program certificate from user { student . id } in program { program_uuid } , a "
676
676
"program certificate could not be found"
677
677
)
678
678
elif exc .response .status_code == 429 :
679
679
# Let celery handle retry attempts and backoff
680
680
error_msg = (
681
- f"Rate limited. Attempting to revoke a program certificate from user { student } in program "
681
+ f"Rate limited. Attempting to revoke a program certificate from user { student . id } in program "
682
682
f"{ program_uuid } ."
683
683
)
684
684
LOGGER .warning (error_msg )
@@ -687,33 +687,33 @@ def revoke_program_certificates(self, username, course_key): # lint-amnesty, py
687
687
) from exc
688
688
else :
689
689
LOGGER .warning (
690
- f"Unable to revoke program certificate from user { student } in program { program_uuid } "
690
+ f"Unable to revoke program certificate from user { student . id } in program { program_uuid } "
691
691
)
692
692
except Exception as exc : # pylint: disable=broad-except
693
693
# keep trying to revoke other certs, but let celery retry the whole task to fix any missing entries
694
694
LOGGER .exception (
695
- f"Failed to revoke program certificate from user { student } in program { program_uuid } : { exc } "
695
+ f"Failed to revoke program certificate from user { student . id } in program { program_uuid } : { exc } "
696
696
)
697
697
failed_program_certificate_revoke_attempts .append (program_uuid )
698
698
699
699
if failed_program_certificate_revoke_attempts :
700
700
# N.B. This logic assumes that this task is idempotent
701
- LOGGER .info (f"Failed task to revoke program certificate(s) from user { student } " )
701
+ LOGGER .info (f"Failed task to revoke program certificate(s) from user { student . id } " )
702
702
# The error message may change on each reattempt but will never be raised until the max number of retries
703
703
# have been exceeded. It is unlikely that this list will change by the time it reaches its maximimum number
704
704
# of attempts.
705
705
error_msg = (
706
- f"Failed to revoke program certificate(s) from user { student } for programs "
706
+ f"Failed to revoke program certificate(s) from user { student . id } for programs "
707
707
f"{ failed_program_certificate_revoke_attempts } "
708
708
)
709
709
raise MaxRetriesExceededError (
710
710
f"Failed to revoke program certificate for user { student .id } for course { course_key } . "
711
711
f"Reason: { error_msg } "
712
712
)
713
713
else :
714
- LOGGER .info (f"No program certificates to revoke from user { student } " )
714
+ LOGGER .info (f"No program certificates to revoke from user { student . id } " )
715
715
716
- LOGGER .info (f"Successfully completed the task revoke_program_certificates for user { student } " )
716
+ LOGGER .info (f"Successfully completed the task revoke_program_certificates for user { student . id } " )
717
717
718
718
719
719
@shared_task (
0 commit comments