update.py 1.09 KB
Newer Older
Guilhem Saurel's avatar
Guilhem Saurel committed
1
2
3
4
5
6
import logging

from django.conf import settings
from django.core.management.base import BaseCommand

from rainboard.models import Branch, Project, Repo, Robotpkg
7
from rainboard.utils import update_robotpkg
Guilhem Saurel's avatar
Guilhem Saurel committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

logger = logging.getLogger('rainboard.management.update')


class Command(BaseCommand):
    help = 'Update the DB'

    def handle(self, *args, **options):
        logger.info(f'\nUpdating all repos\n')
        for repo in Repo.objects.all():
            logger.info(f' {repo}')
            repo.update()

        logger.info(f'\nUpdating all branches\n')
        for branch in Branch.objects.all():
            logger.info(f' {branch}')
            branch.update(pull=False)

        logger.info(f'\nPulling Robotpkg\n')
27
        update_robotpkg(settings.RAINBOARD_RPKG)
Guilhem Saurel's avatar
Guilhem Saurel committed
28
29
30
31
32
33
34
35
36
37

        logger.info(f'\nUpdating Robotpkg\n')
        for robotpkg in Robotpkg.objects.all():
            logger.info(f' {robotpkg}')
            robotpkg.update(pull=False)

        logger.info(f'\nUpdating all projects\n')
        for project in Project.objects.all():
            logger.info(f' {project}')
            project.update()