fix unicode strings in openedx/ part 1

This commit is contained in:
Matthew Piatetsky
2019-02-05 09:44:26 -05:00
committed by Calen Pennington
parent 4b4957ad9f
commit f294b1a374
89 changed files with 323 additions and 315 deletions

View File

@@ -163,7 +163,7 @@ class Command(BaseCommand):
options = self.get_args_from_database()
log.info(
"notify_credentials starting, dry-run=%s, site=%s, delay=%d seconds",
u"notify_credentials starting, dry-run=%s, site=%s, delay=%d seconds",
options['dry_run'],
options['site'],
options['delay']
@@ -175,8 +175,7 @@ class Command(BaseCommand):
try:
site_config = SiteConfiguration.objects.get(site__domain=options['site']) if options['site'] else None
except SiteConfiguration.DoesNotExist:
log.error('No site configuration found for site %s', options['site'])
log.error(u'No site configuration found for site %s', options['site'])
if options['courses']:
course_keys = self.get_course_keys(options['courses'])
cert_filter_args['course_id__in'] = course_keys
@@ -214,11 +213,11 @@ class Command(BaseCommand):
# First, do certs
for i, cert in paged_query(certs, delay, page_size):
if site_config and not site_config.has_org(cert.course_id.org):
log.info("Skipping credential changes %d for certificate %s", i, certstr(cert))
log.info(u"Skipping credential changes %d for certificate %s", i, certstr(cert))
continue
log.info(
"Handling credential changes %d for certificate %s",
u"Handling credential changes %d for certificate %s",
i, certstr(cert),
)
@@ -236,11 +235,11 @@ class Command(BaseCommand):
# Then do grades
for i, grade in paged_query(grades, delay, page_size):
if site_config and not site_config.has_org(grade.course_id.org):
log.info("Skipping grade changes %d for grade %s", i, gradestr(grade))
log.info(u"Skipping grade changes %d for grade %s", i, gradestr(grade))
continue
log.info(
"Handling grade changes %d for grade %s",
u"Handling grade changes %d for grade %s",
i, gradestr(grade),
)
@@ -267,12 +266,12 @@ class Command(BaseCommand):
"""
# Use specific courses if specified, but fall back to all courses.
course_keys = []
log.info("%d courses specified: %s", len(courses), ", ".join(courses))
log.info(u"%d courses specified: %s", len(courses), ", ".join(courses))
for course_id in courses:
try:
course_keys.append(CourseKey.from_string(course_id))
except InvalidKeyError:
log.fatal("%s is not a parseable CourseKey", course_id)
log.fatal(u"%s is not a parseable CourseKey", course_id)
sys.exit(1)
return course_keys
@@ -286,10 +285,10 @@ class Command(BaseCommand):
for cert in certs[:ITEMS_TO_SHOW]:
print(" ", certstr(cert))
if certs.count() > ITEMS_TO_SHOW:
print(" (+ {} more)".format(certs.count() - ITEMS_TO_SHOW))
print(u" (+ {} more)".format(certs.count() - ITEMS_TO_SHOW))
print(grades.count(), "Grades:")
for grade in grades[:ITEMS_TO_SHOW]:
print(" ", gradestr(grade))
if grades.count() > ITEMS_TO_SHOW:
print(" (+ {} more)".format(grades.count() - ITEMS_TO_SHOW))
print(u" (+ {} more)".format(grades.count() - ITEMS_TO_SHOW))

View File

@@ -46,7 +46,7 @@ def send_grade_if_interesting(user, course_run_key, mode, status, letter_grade,
""" Checks if grade is interesting to Credentials and schedules a Celery task if so. """
if verbose:
msg = "Starting send_grade_if_interesting with params: "\
msg = u"Starting send_grade_if_interesting with params: "\
"user [{username}], "\
"course_run_key [{key}], "\
"mode [{mode}], "\
@@ -74,7 +74,7 @@ def send_grade_if_interesting(user, course_run_key, mode, status, letter_grade,
if not helpers.get_value_for_org(course_run_key.org, 'ENABLE_LEARNER_RECORDS', True):
if verbose:
log.info(
"Skipping send grade: ENABLE_LEARNER_RECORDS False for org [{org}]".format(
u"Skipping send grade: ENABLE_LEARNER_RECORDS False for org [{org}]".format(
org=course_run_key.org
)
)
@@ -90,7 +90,7 @@ def send_grade_if_interesting(user, course_run_key, mode, status, letter_grade,
# We only care about grades for which there is a certificate.
if verbose:
log.info(
"Skipping send grade: no cert for user [{username}] & course_id [{course_id}]".format(
u"Skipping send grade: no cert for user [{username}] & course_id [{course_id}]".format(
username=getattr(user, 'username', None),
course_id=str(course_run_key)
)
@@ -103,7 +103,7 @@ def send_grade_if_interesting(user, course_run_key, mode, status, letter_grade,
if mode not in INTERESTING_MODES or status not in INTERESTING_STATUSES:
if verbose:
log.info(
"Skipping send grade: mode/status uninteresting for mode [{mode}] & status [{status}]".format(
u"Skipping send grade: mode/status uninteresting for mode [{mode}] & status [{status}]".format(
mode=mode,
status=status
)
@@ -115,7 +115,7 @@ def send_grade_if_interesting(user, course_run_key, mode, status, letter_grade,
if not is_course_run_in_a_program(course_run_key):
if verbose:
log.info(
"Skipping send grade: course run not in a program. [{course_id}]".format(course_id=str(course_run_key))
u"Skipping send grade: course run not in a program. [{course_id}]".format(course_id=str(course_run_key))
)
return
@@ -125,7 +125,7 @@ def send_grade_if_interesting(user, course_run_key, mode, status, letter_grade,
if grade is None:
if verbose:
log.info(
"Skipping send grade: No grade found for user [{username}] & course_id [{course_id}]".format(
u"Skipping send grade: No grade found for user [{username}] & course_id [{course_id}]".format(
username=getattr(user, 'username', None),
course_id=str(course_run_key)
)

View File

@@ -27,7 +27,7 @@ MAX_RETRIES = 11
@task(bind=True, ignore_result=True, routing_key=ROUTING_KEY)
def send_grade_to_credentials(self, username, course_run_key, verified, letter_grade, percent_grade):
""" Celery task to notify the Credentials IDA of a grade change via POST. """
logger.info('Running task send_grade_to_credentials for username %s and course %s', username, course_run_key)
logger.info(u'Running task send_grade_to_credentials for username %s and course %s', username, course_run_key)
countdown = 2 ** self.request.retries
course_key = CourseKey.from_string(course_run_key)
@@ -46,8 +46,8 @@ def send_grade_to_credentials(self, username, course_run_key, verified, letter_g
'verified': verified,
})
logger.info('Sent grade for course %s to user %s', course_run_key, username)
logger.info(u'Sent grade for course %s to user %s', course_run_key, username)
except Exception as exc:
logger.exception('Failed to send grade for course %s to user %s', course_run_key, username)
logger.exception(u'Failed to send grade for course %s to user %s', course_run_key, username)
raise self.retry(exc=exc, countdown=countdown, max_retries=MAX_RETRIES)