@@ -71,6 +71,5 @@ class Command(BaseCommand):
|
||||
|
||||
if error_keys:
|
||||
msg = 'The following courses encountered errors and were not updated:\n'
|
||||
for error_key in error_keys:
|
||||
msg += f' - {error_key}\n'
|
||||
msg += '\n'.join(f' - {error_key}' for error_key in error_keys)
|
||||
logger.info(msg)
|
||||
|
||||
@@ -51,16 +51,15 @@ class Command(BaseCommand):
|
||||
tarball = tasks.create_export_tarball(library, library_key, {}, None)
|
||||
except Exception as e:
|
||||
raise CommandError(f'Failed to export "{library_key}" with "{e}"') # lint-amnesty, pylint: disable=raise-missing-from
|
||||
else:
|
||||
with tarball:
|
||||
# Save generated archive with keyed filename
|
||||
prefix, suffix, n = str(library_key).replace(':', '+'), '.tar.gz', 0
|
||||
while os.path.exists(prefix + suffix):
|
||||
n += 1
|
||||
prefix = '{}_{}'.format(prefix.rsplit('_', 1)[0], n) if n > 1 else f'{prefix}_1'
|
||||
filename = prefix + suffix
|
||||
target = os.path.join(dest_path, filename)
|
||||
tarball.file.seek(0)
|
||||
with open(target, 'wb') as f:
|
||||
shutil.copyfileobj(tarball.file, f)
|
||||
print(f'Library "{library.location.library_key}" exported to "{target}"')
|
||||
with tarball:
|
||||
# Save generated archive with keyed filename
|
||||
prefix, suffix, n = str(library_key).replace(':', '+'), '.tar.gz', 0
|
||||
while os.path.exists(prefix + suffix):
|
||||
n += 1
|
||||
prefix = '{}_{}'.format(prefix.rsplit('_', 1)[0], n) if n > 1 else f'{prefix}_1'
|
||||
filename = prefix + suffix
|
||||
target = os.path.join(dest_path, filename)
|
||||
tarball.file.seek(0)
|
||||
with open(target, 'wb') as f:
|
||||
shutil.copyfileobj(tarball.file, f)
|
||||
print(f'Library "{library.location.library_key}" exported to "{target}"')
|
||||
|
||||
@@ -81,7 +81,7 @@ class Command(BaseCommand):
|
||||
self.change_enrollments(csv_file)
|
||||
|
||||
else:
|
||||
CommandError('No file is provided. File is required')
|
||||
raise CommandError('No file is provided. File is required')
|
||||
|
||||
def change_enrollments(self, csv_file):
|
||||
""" change the enrollments of the learners. """
|
||||
|
||||
@@ -205,9 +205,8 @@ def track_segmentio_event(request): # pylint: disable=too-many-statements
|
||||
raise EventValidationError(ERROR_USER_NOT_EXIST) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
except ValueError:
|
||||
raise EventValidationError(ERROR_INVALID_USER_ID) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
else:
|
||||
context['user_id'] = user.id
|
||||
context['username'] = user.username
|
||||
context['user_id'] = user.id
|
||||
context['username'] = user.username
|
||||
|
||||
# course_id is expected to be provided in the context when applicable
|
||||
course_id = context.get('course_id')
|
||||
|
||||
@@ -1010,7 +1010,7 @@ def get_thread_list(
|
||||
if view in ["unread", "unanswered", "unresponded"]:
|
||||
query_params[view] = "true"
|
||||
else:
|
||||
ValidationError({
|
||||
raise ValidationError({
|
||||
"view": [f"Invalid value. '{view}' must be 'unread' or 'unanswered'"]
|
||||
})
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ class ExperimentWaffleFlag(CourseWaffleFlag):
|
||||
if (
|
||||
track and hasattr(request, 'session') and
|
||||
session_key not in request.session and
|
||||
not masquerading_as_specific_student and not anonymous
|
||||
not masquerading_as_specific_student and not anonymous # pylint: disable=used-before-assignment
|
||||
):
|
||||
segment.track(
|
||||
user_id=user.id,
|
||||
|
||||
@@ -92,8 +92,7 @@ def render_press_release(request, slug):
|
||||
resp = render_to_response('static_templates/press_releases/' + template, {})
|
||||
except TemplateDoesNotExist:
|
||||
raise Http404 # lint-amnesty, pylint: disable=raise-missing-from
|
||||
else:
|
||||
return resp
|
||||
return resp
|
||||
|
||||
|
||||
@fix_crum_request
|
||||
|
||||
@@ -41,8 +41,7 @@ def update_credit_course_requirements(course_id):
|
||||
except (InvalidKeyError, ItemNotFoundError, InvalidCreditRequirements) as exc:
|
||||
LOGGER.error('Error on adding the requirements for course %s - %s', course_id, str(exc))
|
||||
raise update_credit_course_requirements.retry(args=[course_id], exc=exc)
|
||||
else:
|
||||
LOGGER.info('Requirements added for course %s', course_id)
|
||||
LOGGER.info('Requirements added for course %s', course_id)
|
||||
|
||||
|
||||
def _get_course_credit_requirements(course_key):
|
||||
|
||||
@@ -341,8 +341,7 @@ def get_course_enrollment_info(course_id, include_expired=False):
|
||||
msg = f"Requested enrollment information for unknown course {course_id}"
|
||||
log.warning(msg)
|
||||
raise CourseNotFoundError(msg) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
else:
|
||||
return CourseSerializer(course, include_expired=include_expired).data
|
||||
return CourseSerializer(course, include_expired=include_expired).data
|
||||
|
||||
|
||||
def get_user_roles(username):
|
||||
|
||||
@@ -244,14 +244,13 @@ class SafeCookieData:
|
||||
raise SafeCookieError( # lint-amnesty, pylint: disable=raise-missing-from
|
||||
f"SafeCookieData BWC parse error: {safe_cookie_string!r}."
|
||||
)
|
||||
else:
|
||||
if safe_cookie_data.version != cls.CURRENT_VERSION:
|
||||
raise SafeCookieError(
|
||||
"SafeCookieData version {!r} is not supported. Current version is {}.".format(
|
||||
safe_cookie_data.version,
|
||||
cls.CURRENT_VERSION,
|
||||
))
|
||||
return safe_cookie_data
|
||||
if safe_cookie_data.version != cls.CURRENT_VERSION:
|
||||
raise SafeCookieError(
|
||||
"SafeCookieData version {!r} is not supported. Current version is {}.".format(
|
||||
safe_cookie_data.version,
|
||||
cls.CURRENT_VERSION,
|
||||
))
|
||||
return safe_cookie_data
|
||||
|
||||
def __str__(self):
|
||||
"""
|
||||
|
||||
@@ -135,11 +135,10 @@ class Command(BaseCommand):
|
||||
optout_rows[end_idx][0], optout_rows[end_idx][1],
|
||||
str(err))
|
||||
raise
|
||||
else:
|
||||
cursor.execute('COMMIT;')
|
||||
log.info("Committed opt-out for rows (%s, %s) through (%s, %s).",
|
||||
optout_rows[start_idx][0], optout_rows[start_idx][1],
|
||||
optout_rows[end_idx][0], optout_rows[end_idx][1])
|
||||
cursor.execute('COMMIT;')
|
||||
log.info("Committed opt-out for rows (%s, %s) through (%s, %s).",
|
||||
optout_rows[start_idx][0], optout_rows[start_idx][1],
|
||||
optout_rows[end_idx][0], optout_rows[end_idx][1])
|
||||
log.info("Sleeping %s seconds...", sleep_between)
|
||||
time.sleep(sleep_between)
|
||||
curr_row_idx += chunk_size
|
||||
|
||||
@@ -265,8 +265,7 @@ class LazySequence(Sequence):
|
||||
|
||||
def __iter__(self):
|
||||
# Yield all the known data first
|
||||
for item in self._data:
|
||||
yield item
|
||||
yield from self._data
|
||||
|
||||
# Capture and yield data from the underlying iterator
|
||||
# until it is exhausted
|
||||
|
||||
@@ -50,9 +50,8 @@ def emulate_http_request(site=None, user=None, middleware_classes=None):
|
||||
for middleware in reversed(middleware_instances):
|
||||
_run_method_if_implemented(middleware, 'process_exception', request, exc)
|
||||
raise
|
||||
else:
|
||||
for middleware in reversed(middleware_instances):
|
||||
_run_method_if_implemented(middleware, 'process_response', request, response)
|
||||
for middleware in reversed(middleware_instances):
|
||||
_run_method_if_implemented(middleware, 'process_response', request, response)
|
||||
|
||||
|
||||
def _run_method_if_implemented(instance, method_name, *args, **kwargs):
|
||||
|
||||
7
pylintrc
7
pylintrc
@@ -321,11 +321,6 @@ disable =
|
||||
superfluous-parens,
|
||||
logging-not-lazy,
|
||||
broad-exception-caught,
|
||||
no-else-raise,
|
||||
pointless-exception-statement,
|
||||
consider-using-join,
|
||||
use-yield-from,
|
||||
used-before-assignment,
|
||||
|
||||
[REPORTS]
|
||||
output-format = text
|
||||
@@ -422,4 +417,4 @@ int-import-graph =
|
||||
[EXCEPTIONS]
|
||||
overgeneral-exceptions = builtins.Exception
|
||||
|
||||
# 86de3cc2b03ecf7e6f6f9f2d5f790bb9e7c3eb4c
|
||||
# 85c3d025c367597a0a7b23a05fdde9d8c63e1374
|
||||
|
||||
@@ -40,12 +40,6 @@ disable+ =
|
||||
superfluous-parens,
|
||||
logging-not-lazy,
|
||||
broad-exception-caught,
|
||||
no-else-raise,
|
||||
pointless-exception-statement,
|
||||
consider-using-join,
|
||||
use-yield-from,
|
||||
used-before-assignment,
|
||||
|
||||
|
||||
[BASIC]
|
||||
attr-rgx = [a-z_][a-z0-9_]{2,40}$
|
||||
|
||||
@@ -76,8 +76,7 @@ class TemplateTestCase(unittest.TestCase):
|
||||
except Exception as exc:
|
||||
raise TemplateError("Could not parse XML from '{0}': {1}".format( # lint-amnesty, pylint: disable=raise-missing-from
|
||||
xml_str, str(exc)))
|
||||
else:
|
||||
return xml
|
||||
return xml
|
||||
|
||||
def assert_has_xpath(self, xml_root, xpath, context_dict, exact_num=1):
|
||||
"""
|
||||
|
||||
@@ -419,9 +419,8 @@ class SplitTestBlock( # lint-amnesty, pylint: disable=abstract-method
|
||||
)
|
||||
)
|
||||
raise
|
||||
else:
|
||||
self.runtime.publish(self, 'xblock.split_test.child_render', {'child_id': child_id})
|
||||
return Response()
|
||||
self.runtime.publish(self, 'xblock.split_test.child_render', {'child_id': child_id})
|
||||
return Response()
|
||||
|
||||
def get_icon_class(self):
|
||||
return self.child.get_icon_class() if self.child else 'other'
|
||||
|
||||
Reference in New Issue
Block a user