Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions scripts/embargo_registrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from framework.celery_tasks import app as celery_app

from website import settings
from osf.models import Embargo, Registration, NodeLog
from osf.models import Embargo, Registration

from scripts import utils as scripts_utils

Expand Down Expand Up @@ -59,12 +59,22 @@ def main(dry_run=True):
embargo.accept()
transaction.savepoint_commit(sid)
except Exception as err:
root = parent_registration._dirty_root
embargo = root.embargo

logger.error(
f'Unexpected error raised when activating embargo for '
f'registration {parent_registration._id}. Continuing...'
f'registration {parent_registration._id}. Error: {err}',
exc_info=err,
extra={
'is_public': root.is_public,
'approval_stage': embargo.approval_stage.name,
'is_approved': root.embargo.is_approved
}
)
logger.exception(err)
sentry.log_message(str(err))
sentry.log_exception(err)

transaction.savepoint_rollback(sid)

active_embargoes = Embargo.objects.filter(state=Embargo.APPROVED)
Expand All @@ -89,11 +99,21 @@ def main(dry_run=True):
parent_registration.terminate_embargo()
transaction.savepoint_commit(sid)
except Exception as err:
root = parent_registration._dirty_root
embargo = root.embargo

logger.error(
f'Registration {parent_registration._id} could not be made public because {str(err)}',
exc_info=err
exc_info=err,
extra={
'is_public': root.is_public,
'approval_stage': embargo.approval_stage.name,
'is_approved': root.embargo.is_approved
}
)
sentry.log_message(f'Registration {parent_registration._id} could not be made public because {str(err)}')
logger.exception(err)
sentry.log_exception(err)

transaction.savepoint_rollback(sid)


Expand Down
Loading