Example #1
0
    def handle(self, *args, **options):
        """
        Collect the projects we want to sync and trigger worker jobs to
        sync each one.
        """
        sync_log = SyncLog.objects.create(start_time=timezone.now())

        projects = Project.objects.filter(disabled=False)
        if args:
            projects = projects.filter(slug__in=args)

        if len(projects) < 1:
            raise CommandError('No matching projects found.')

        if args and len(projects) != len(args):
            invalid_slugs = sorted(set(args).difference(set(projects.values_list('slug', flat=True))))
            self.stderr.write('Couldn\'t find projects with following slugs: {}'.format(', '.join(invalid_slugs)))

        for project in projects:
            if not project.can_commit:
                self.stdout.write(u'Skipping project {0}, cannot commit to repository.'
                                  .format(project.name))
            else:
                self.stdout.write(u'Scheduling sync for project {0}.'.format(project.name))
                sync_project.delay(
                    project.pk,
                    sync_log.pk,
                    no_pull=options['no_pull'],
                    no_commit=options['no_commit'],
                    force=options['force'],
                )
Example #2
0
    def handle(self, *args, **options):
        """
        Collect the projects we want to sync and trigger worker jobs to
        sync each one.
        """
        sync_log = SyncLog.objects.create(start_time=timezone.now())

        projects = Project.objects.filter(disabled=False)
        if args:
            projects = projects.filter(slug__in=args)

        if len(projects) < 1:
            raise CommandError('No matching projects found.')

        for project in projects:
            if not project.can_commit:
                self.stdout.write(u'Skipping project {0}, cannot commit to repository.'
                                  .format(project.name))
            else:
                self.stdout.write(u'Scheduling sync for project {0}.'.format(project.name))
                sync_project.delay(
                    project.pk,
                    sync_log.pk,
                    no_pull=options['no_pull'],
                    no_commit=options['no_commit'],
                    force=options['force'],
                )
Example #3
0
def manually_sync_project(request, slug):
    if not request.user.has_perm('base.can_manage') or not settings.MANUAL_SYNC:
        return HttpResponseForbidden(
            "Forbidden: You don't have permission for syncing projects"
        )

    sync_log = SyncLog.objects.create(start_time=timezone.now())
    project = Project.objects.get(slug=slug)
    sync_project.delay(project.pk, sync_log.pk)

    return HttpResponse('ok')
Example #4
0
def manually_sync_project(request, slug):
    if not request.user.has_perm('base.can_manage') or not settings.MANUAL_SYNC:
        return HttpResponseForbidden(
            "Forbidden: You don't have permission for syncing projects"
        )

    sync_log = SyncLog.objects.create(start_time=timezone.now())
    project = Project.objects.get(slug=slug)
    sync_project.delay(project.pk, sync_log.pk)

    return HttpResponse('ok')
Example #5
0
    def handle(self, *args, **options):
        """
        Collect the projects we want to sync and trigger worker jobs to
        sync each one.
        """
        sync_log = SyncLog.objects.create(start_time=timezone.now())

        projects = Project.objects.syncable()
        slugs = (
            options['projects'].split(',') if 'projects' in options and options['projects']
            else None
        )
        if slugs:
            projects = projects.filter(slug__in=slugs)

        if len(projects) < 1:
            raise CommandError('No matching projects found.')

        if slugs and len(projects) != len(slugs):
            invalid_slugs = sorted(
                set(slugs).difference(set(projects.values_list('slug', flat=True)))
            )
            self.stderr.write(
                "Couldn't find projects with following slugs: {}".format(
                    ', '.join(invalid_slugs)
                )
            )

        locale = None
        if options['locale']:
            try:
                locale = Locale.objects.get(code=options['locale'])
            except Locale.DoesNotExist:
                raise CommandError('No matching locale found.')

        for project in projects:
            if not project.can_commit:
                self.stdout.write(u'Skipping project {0}, cannot commit to repository.'
                                  .format(project.name))
            else:
                self.stdout.write(u'Scheduling sync for project {0}.'.format(project.name))
                sync_project.delay(
                    project.pk,
                    sync_log.pk,
                    locale=locale,
                    no_pull=options['no_pull'],
                    no_commit=options['no_commit'],
                    force=options['force'],
                )
Example #6
0
    def handle(self, *args, **options):
        """
        Collect the projects we want to sync and trigger worker jobs to
        sync each one.
        """
        sync_log = SyncLog.objects.create(start_time=timezone.now())

        projects = Project.objects.filter(disabled=False,
                                          data_source='repository')
        slugs = (options['projects'].split(',')
                 if 'projects' in options and options['projects'] else None)
        if slugs:
            projects = projects.filter(slug__in=slugs)

        if len(projects) < 1:
            raise CommandError('No matching projects found.')

        if slugs and len(projects) != len(slugs):
            invalid_slugs = sorted(
                set(slugs).difference(
                    set(projects.values_list('slug', flat=True))))
            self.stderr.write(
                "Couldn't find projects with following slugs: {}".format(
                    ', '.join(invalid_slugs)))

        locale = None
        if options['locale']:
            try:
                locale = Locale.objects.get(code=options['locale'])
            except Locale.DoesNotExist:
                raise CommandError('No matching locale found.')

        for project in projects:
            if not project.can_commit:
                self.stdout.write(
                    u'Skipping project {0}, cannot commit to repository.'.
                    format(project.name))
            else:
                self.stdout.write(u'Scheduling sync for project {0}.'.format(
                    project.name))
                sync_project.delay(
                    project.pk,
                    sync_log.pk,
                    locale=locale,
                    no_pull=options['no_pull'],
                    no_commit=options['no_commit'],
                    force=options['force'],
                )
Example #7
0
    def handle(self, *args, **options):
        """
        Collect the projects we want to sync and trigger worker jobs to
        sync each one.
        """
        sync_log = SyncLog.objects.create(start_time=timezone.now())

        projects = Project.objects.syncable()
        slugs = (options["projects"].split(",")
                 if "projects" in options and options["projects"] else None)
        if slugs:
            projects = projects.filter(slug__in=slugs)

        if len(projects) < 1:
            raise CommandError("No matching projects found.")

        if slugs and len(projects) != len(slugs):
            invalid_slugs = sorted(
                set(slugs).difference(
                    set(projects.values_list("slug", flat=True))))
            self.stderr.write(
                "Couldn't find projects with following slugs: {}".format(
                    ", ".join(invalid_slugs)))

        locale = None
        if options["locale"]:
            try:
                locale = Locale.objects.get(code=options["locale"])
            except Locale.DoesNotExist:
                raise CommandError("No matching locale found.")

        for project in projects:
            if not project.can_commit:
                self.stdout.write(
                    u"Skipping project {0}, cannot commit to repository.".
                    format(project.name))
            else:
                self.stdout.write(u"Scheduling sync for project {0}.".format(
                    project.name))
                sync_project.delay(
                    project.pk,
                    sync_log.pk,
                    locale=locale,
                    no_pull=options["no_pull"],
                    no_commit=options["no_commit"],
                    force=options["force"],
                )
Example #8
0
    def handle(self, *args, **options):
        """
        Collect the projects we want to sync and trigger worker jobs to
        sync each one.
        """
        sync_log = SyncLog.objects.create(start_time=timezone.now())

        projects = Project.objects.filter(disabled=False)
        if args:
            projects = projects.filter(slug__in=args)

        if len(projects) < 1:
            raise CommandError('No matching projects found.')

        if args and len(projects) != len(args):
            invalid_slugs = sorted(
                set(args).difference(
                    set(projects.values_list('slug', flat=True))))
            self.stderr.write(
                'Couldn\'t find projects with following slugs: {}'.format(
                    ', '.join(invalid_slugs)))

        for project in projects:
            if not project.can_commit:
                self.stdout.write(
                    u'Skipping project {0}, cannot commit to repository.'.
                    format(project.name))
            else:
                self.stdout.write(u'Scheduling sync for project {0}.'.format(
                    project.name))
                sync_project.delay(
                    project.pk,
                    sync_log.pk,
                    no_pull=options['no_pull'],
                    no_commit=options['no_commit'],
                    force=options['force'],
                )
Example #9
0
    def handle(self, *args, **options):
        """
        Collect the projects we want to sync and trigger worker jobs to
        sync each one.
        """
        sync_log = SyncLog.objects.create(start_time=timezone.now())

        if options["force"]:
            projects = Project.objects.force_syncable()
        else:
            projects = Project.objects.syncable()

        slugs = (options["projects"].split(",")
                 if "projects" in options and options["projects"] else None)
        if slugs:
            projects = projects.filter(slug__in=slugs)

        if len(projects) < 1:
            raise CommandError("No matching projects to sync found.")

        if slugs and len(projects) != len(slugs):
            invalid_slugs = sorted(
                set(slugs).difference(
                    set(projects.values_list("slug", flat=True))))
            self.stderr.write(
                "Couldn't find projects to sync with following slugs: {}".
                format(", ".join(invalid_slugs)))

        for project in projects:
            self.stdout.write(f"Scheduling sync for project {project.name}.")
            sync_project.delay(
                project.pk,
                sync_log.pk,
                no_pull=options["no_pull"],
                no_commit=options["no_commit"],
                force=options["force"],
            )