fix repair_resource management command
@@ -47,42 +47,25 @@ class Command(BaseCommand):
for rid in options['resource_ids']:
try:
resource = get_resource_by_shortkey(rid)
- except BaseResource.NotFoundException:
- msg = "resource {} not found".format(rid)
- print(msg)
- continue
- _, count = repair_resource(resource,
+ repair_resource(resource, logger,
echo_errors=echo_errors,
log_errors=log_errors,
return_errors=False)
- if count:
- msg = "... affected resource {} has type {}, title '{}'"\
- .format(resource.short_id, resource.resource_type,
- resource.title)
- if log_errors:
- logger.info(msg)
- if echo_errors:
+ except BaseResource.NotFoundException:
+ msg = "resource {} not found".format(rid)
print(msg)
+ continue
else: # check all resources
print("REPAIRING ALL RESOURCES")
for r in BaseResource.objects.all():
try:
resource = get_resource_by_shortkey(r.short_id)
- except BaseResource.NotFoundException:
- msg = "resource {} not found".format(rid)
- print(msg)
- continue
-
- _, count = repair_resource(resource,
+ repair_resource(resource, logger,
echo_errors=echo_errors,
log_errors=log_errors,
return_errors=False)
- if count:
- msg = "... affected resource {} has type {}, title '{}'"\
- .format(resource.short_id, resource.resource_type,
- resource.title)
- if log_errors:
- logger.info(msg)
- if echo_errors:
+ except BaseResource.NotFoundException:
+ msg = "resource {} not found".format(r.short_id)
print(msg)
+ continue
