diff --git a/livesync/indico_livesync/cli.py b/livesync/indico_livesync/cli.py index 9a3fd19..55a7d9d 100644 --- a/livesync/indico_livesync/cli.py +++ b/livesync/indico_livesync/cli.py @@ -54,7 +54,11 @@ def agents(): for agent in agent_list: initial = (cformat('%{green!}done%{reset}') if agent.initial_data_exported else cformat('%{yellow!}pending%{reset}')) - table_data.append([unicode(agent.id), agent.name, agent.backend.title, initial, unicode(agent.queue.count())]) + if agent.backend is None: + backend_title = cformat('%{red!}invalid backend ({})%{reset}').format(agent.backend_name) + else: + backend_title = agent.backend.title + table_data.append([unicode(agent.id), agent.name, backend_title, initial, unicode(agent.queue.count())]) table = AsciiTable(table_data) table.justify_columns[4] = 'right' print table.table @@ -74,6 +78,9 @@ def initial_export(agent_id, force=False): if agent is None: print 'No such agent' return + if agent.backend is None: + print cformat('Cannot run agent %{red!}{}%{reset} (backend not found)').format(agent.name) + return print cformat('Selected agent: %{white!}{}%{reset} ({})').format(agent.name, agent.backend.title) if agent.initial_data_exported and not force: print 'The initial export has already been performed for this agent.' @@ -127,6 +134,9 @@ def run(agent_id=None): agent_list = [agent] for agent in agent_list: + if agent.backend is None: + print cformat('Skipping agent: %{red!}{}%{reset} (backend not found)').format(agent.name) + continue if not agent.initial_data_exported: print cformat('Skipping agent: %{red!}{}%{reset} (initial export not performed)').format(agent.name) continue diff --git a/livesync/indico_livesync/task.py b/livesync/indico_livesync/task.py index 93473b1..639da48 100644 --- a/livesync/indico_livesync/task.py +++ b/livesync/indico_livesync/task.py @@ -41,6 +41,9 @@ class LiveSyncTask(PeriodicUniqueTask): plugin = LiveSyncPlugin.instance # RuntimeError if not active with plugin.plugin_context(): for agent in LiveSyncAgent.find_all(): + if agent.backend is None: + self.logger.warning('Skipping agent {}; backend not found'.format(agent.name)) + continue if not agent.initial_data_exported: self.logger.warning('Skipping agent {}; initial export not performed yet'.format(agent.name)) continue