From 4aba0caecabffe08fcbb46ebcd438c9b96a6180f Mon Sep 17 00:00:00 2001 From: marwoodandrew Date: Thu, 20 Oct 2022 16:23:50 +1100 Subject: [PATCH] [SDAAP-24] fix ability to run single data updates from planning. --- superdesk/commands/data_updates.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/superdesk/commands/data_updates.py b/superdesk/commands/data_updates.py index cbac6875ce..f83efdb85b 100644 --- a/superdesk/commands/data_updates.py +++ b/superdesk/commands/data_updates.py @@ -116,7 +116,6 @@ class DataUpdateCommand(superdesk.Command): "-i", dest="data_update_id", required=False, - choices=get_data_updates_files(strip_file_extension=True), help="Data update id to run last", ), superdesk.Option( @@ -181,6 +180,10 @@ class Upgrade(DataUpdateCommand): """ def run(self, data_update_id=None, fake=False, dry=False): + if data_update_id and data_update_id not in get_data_updates_files(strip_file_extension=True): + print("Error argument --id/-i: invalid choice: '{}'" + " (choose from {})".format(data_update_id, get_data_updates_files(strip_file_extension=True))) + return super().run(data_update_id, fake, dry) data_updates_files = self.data_updates_files # drops updates that already have been applied @@ -218,6 +221,10 @@ class Downgrade(DataUpdateCommand): """ def run(self, data_update_id=None, fake=False, dry=False): + if data_update_id and data_update_id not in get_data_updates_files(strip_file_extension=True): + print("Error argument --id/-i: invalid choice: '{}'" + " (choose from {})".format(data_update_id, get_data_updates_files(strip_file_extension=True))) + return super().run(data_update_id, fake, dry) data_updates_files = self.data_updates_files # check if there is something to downgrade