added error checking to stats resources-details function
@@ -151,10 +151,12 @@ class Command(BaseCommand):
'user id'
]
w.writerow(fields)
-
+ failed_resource_ids = []
for r in BaseResource.objects.all():
+ try:
values = [
- r.metadata.dates.get(type="created").start_date.strftime("%m/%d/%Y %H:%M:%S.%f"),
+ r.metadata.dates.get(type="created").
+ start_date.strftime("%m/%d/%Y %H:%M:%S.%f"),
r.metadata.title.value,
r.resource_type,
r.size,
@@ -164,6 +166,16 @@ class Command(BaseCommand):
]
w.writerow([unicode(v).encode("utf-8") for v in values])
+ except Exception as e:
+ err.error(e)
+
+ # save the id of the broken resource
+ failed_resource_ids.append(r.short_id)
+
+ # print all failed resources for debugging purposes
+ for f in failed_resource_ids:
+ err.error('Error processing resource: %s' % f)
+
def yesterdays_variables(self, lookback=1):
today_start = timezone.datetime.now().replace(
