Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/cli/admin.py
# Copyright (C) 2017-2019 The Software Heritage developers | # Copyright (C) 2017-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import click | import click | ||||
from swh.deposit.config import setup_django_for | from swh.deposit.config import setup_django_for | ||||
from swh.deposit.cli import deposit | from swh.deposit.cli import deposit | ||||
▲ Show 20 Lines • Show All 246 Lines • ▼ Show 20 Lines | if not task_id: | ||||
"Deposit %s cannot be rescheduled. It misses the " | "Deposit %s cannot be rescheduled. It misses the " | ||||
"associated task." % deposit_id | "associated task." % deposit_id | ||||
) | ) | ||||
ctx.exit(1) | ctx.exit(1) | ||||
# Reset the deposit's state | # Reset the deposit's state | ||||
deposit.swh_id = None | deposit.swh_id = None | ||||
deposit.swh_id_context = None | deposit.swh_id_context = None | ||||
deposit.swh_anchor_id = None | |||||
deposit.swh_anchor_id_context = None | |||||
deposit.status = DEPOSIT_STATUS_VERIFIED | deposit.status = DEPOSIT_STATUS_VERIFIED | ||||
deposit.save() | deposit.save() | ||||
# Trigger back the deposit | # Trigger back the deposit | ||||
scheduler = SWHDefaultConfig().scheduler | scheduler = SWHDefaultConfig().scheduler | ||||
scheduler.set_status_tasks( | scheduler.set_status_tasks( | ||||
[task_id], status="next_run_not_scheduled", next_run=datetime.now() | [task_id], status="next_run_not_scheduled", next_run=datetime.now() | ||||
) | ) |