Skip to content
Snippets Groups Projects
Commit ad844dc4 authored by Olivier Le Brouster's avatar Olivier Le Brouster
Browse files

handle error on deletion

parent 03aca0e5
No related branches found
No related tags found
No related merge requests found
......@@ -113,8 +113,15 @@ class Command(BaseCommand):
def _delete_event(self, wrapper, estim_event, until):
event = getattr(estim_event, 'event', None)
if event is None:
wrapper.remove(estim_event, production=not self.dry_run)
self._info('* DELETION (event not found) {} [{}]'.format(estim_event, estim_event.data_hash))
try:
wrapper.remove(estim_event, production=not self.dry_run)
except EstimEventTemporaryError, e:
estim_event.status = EstimEvent.STATUS_TEMPORARY_ERROR
estim_event.message = force_text(e)[:1024]
self._warning('* TEMPORARY ERROR ON DELETION: {} - {} - {} [{}]'.format(event.pk, estim_event.key['date_debut'], event, estim_event.data_hash))
self._warning(' %s' % estim_event.message)
else:
self._info('* DELETION (event not found) {} [{}]'.format(estim_event, estim_event.data_hash))
return
if not wrapper.has_to_keep(event):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment