Coverage for distro_tracker/core/management/commands/tracker_run_all_tasks.py: 100%
19 statements
« prev ^ index » next coverage.py v6.5.0, created at 2025-01-12 09:15 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2025-01-12 09:15 +0000
1# Copyright 2013-2018 The Distro Tracker Developers
2# See the COPYRIGHT file at the top-level directory of this distribution and
3# at https://deb.li/DTAuthors
4#
5# This file is part of Distro Tracker. It is subject to the license terms
6# in the LICENSE file found in the top-level directory of this
7# distribution and at https://deb.li/DTLicense. No part of Distro Tracker,
8# including this file, may be copied, modified, propagated, or distributed
9# except according to the terms contained in the LICENSE file.
10"""
11Implements a command which starts all independent Distro Tracker tasks.
12A task is a subclass of :class:`distro_tracker.core.tasks.BaseTask`.
13"""
14import logging
16from django.core.management.base import BaseCommand
18from distro_tracker.core.tasks import run_all_tasks
20logger = logging.getLogger('distro_tracker.tasks')
23class Command(BaseCommand):
24 """
25 A management command which starts all Distro Tracker tasks that can
26 be run according to their scheduling policy.
27 """
28 help = "Start all Distro Tracker tasks that can be run." # noqa
30 def add_arguments(self, parser):
31 parser.add_argument(
32 '--force-update',
33 action='store_true',
34 dest='force_update',
35 default=False,
36 help=(
37 'Force the update. '
38 'This clears any caches and makes a full update'
39 )
40 )
41 parser.add_argument(
42 '--fake-update',
43 action='store_true',
44 dest='fake_update',
45 default=False,
46 help=(
47 'Instruct the task to not do anything except recording that '
48 'everything has been done.'
49 )
50 )
52 def handle(self, *args, **kwargs):
53 params = {}
54 if kwargs['force_update']:
55 params['force_update'] = True
56 if kwargs['fake_update']:
57 params['fake_update'] = True
58 logger.info(
59 'Starting all tasks (from ./manage.py tracker_run_all_tasks')
60 run_all_tasks(**params)
61 logger.info(
62 'Finished to run all tasks (from ./manage.py tracker_run_all_tasks')