Skip to content

Commit f46cbee

Browse files
authored
[ENG-9653] Rebased ENG-9653 onto up-to-date pbs branch #11547
## Ticket https://openscience.atlassian.net/browse/ENG-9653
2 parents 3fb6b4f + 107cd37 commit f46cbee

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

scripts/embargo_registrations.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from framework.celery_tasks import app as celery_app
1919

2020
from website import settings
21-
from osf.models import Embargo, Registration, NodeLog
21+
from osf.models import Embargo, Registration
2222

2323
from scripts import utils as scripts_utils
2424

@@ -59,12 +59,22 @@ def main(dry_run=True):
5959
embargo.accept()
6060
transaction.savepoint_commit(sid)
6161
except Exception as err:
62+
root = parent_registration._dirty_root
63+
embargo = root.embargo
64+
6265
logger.error(
6366
f'Unexpected error raised when activating embargo for '
64-
f'registration {parent_registration._id}. Continuing...'
67+
f'registration {parent_registration._id}. Error: {err}',
68+
exc_info=err,
69+
extra={
70+
'is_public': root.is_public,
71+
'approval_stage': embargo.approval_stage.name,
72+
'is_approved': root.embargo.is_approved
73+
}
6574
)
6675
logger.exception(err)
67-
sentry.log_message(str(err))
76+
sentry.log_exception(err)
77+
6878
transaction.savepoint_rollback(sid)
6979

7080
active_embargoes = Embargo.objects.filter(state=Embargo.APPROVED)
@@ -89,11 +99,21 @@ def main(dry_run=True):
8999
parent_registration.terminate_embargo()
90100
transaction.savepoint_commit(sid)
91101
except Exception as err:
102+
root = parent_registration._dirty_root
103+
embargo = root.embargo
104+
92105
logger.error(
93106
f'Registration {parent_registration._id} could not be made public because {str(err)}',
94-
exc_info=err
107+
exc_info=err,
108+
extra={
109+
'is_public': root.is_public,
110+
'approval_stage': embargo.approval_stage.name,
111+
'is_approved': root.embargo.is_approved
112+
}
95113
)
96-
sentry.log_message(f'Registration {parent_registration._id} could not be made public because {str(err)}')
114+
logger.exception(err)
115+
sentry.log_exception(err)
116+
97117
transaction.savepoint_rollback(sid)
98118

99119

0 commit comments

Comments
 (0)