Example #1
0
    def handle(self, *args, **options):

        for project in Project.objects.filter(deleted = False):

            repo = get_repo(project.username, project.repository)

            if(repo and 'description' in repo and
                    repo['description']):
                project.description = repo['description']
            
                self.stdout.write(str(project) + ': ' +\
                        project.description)
            else:
                self.stdout.write('No description found: ' + str(project))

            project.save()
Example #2
0
def add_project(request):
    if request.method == 'POST':
        form = ProjectForm(request.POST)

        if form.is_valid():
            package = form.cleaned_data['package']
            username = form.cleaned_data['username']
            repository = form.cleaned_data['repository']
            branch = form.cleaned_data['branch']
            cargo_support = form.cleaned_data['cargo_support']
            categories = form.cleaned_data['categories']

            repo = travisclient.get_repo(username, repository)

            if not repo:
                error_message = 'Unable to get Travis CI repo: {}/{}'.\
                    format(username, repository)
                return index(request, error_message)

            project = Project(package=package,
                              username=username,
                              repository=repository,
                              branch=branch,
                              cargo_support=cargo_support)

            if ('description' in repo and repo['description']):
                project.description = repo['description']
            else:
                project.description = ''
            project.save()

            # Set categories
            project.categories = categories
            project.save()

            return authenticate_with_github(request, project.id, 'add_project')

    else:
        form = ProjectForm(initial={'branch': 'master'})

    context = {
        'title': private_settings.APP_TITLE,
        'form': form,
        'categories': ProjectCategory.objects.all()
    }
    return render(request, 'ppatrigger/project_form.html', context)
Example #3
0
def add_project(request):
    if request.method == 'POST':
        form = ProjectForm(request.POST)

        if form.is_valid():
            package = form.cleaned_data['package']
            username = form.cleaned_data['username']
            repository = form.cleaned_data['repository']
            branch = form.cleaned_data['branch']
            cargo_support = form.cleaned_data['cargo_support']
            categories = form.cleaned_data['categories']

            repo = travisclient.get_repo(username, repository)

            if not repo:
                error_message = 'Unable to get Travis CI repo: {}/{}'.\
                    format(username, repository)
                return index(request, error_message)

            project = Project(package = package, username = username,
                    repository = repository, branch = branch,
                    cargo_support = cargo_support)
           
            if('description' in repo and repo['description']):
                project.description = repo['description']
            else:
                project.description = ''
            project.save()

            # Set categories
            project.categories = categories
            project.save()

            return authenticate_with_github(request, project.id,
                    'add_project')

    else:
        form = ProjectForm(initial={'branch': 'master'})

    context = {
            'title': private_settings.APP_TITLE,
            'form': form,
            'categories': ProjectCategory.objects.all()
    }
    return render(request, 'ppatrigger/project_form.html', context)
Example #4
0
    def handle(self, *args, **options):


        projects = Project.objects.filter(build_started__exact = True,
                deleted = False)

        if not len(projects):
            self.stdout.write('fetchbuilds: No started builds.')
        else:

            self.stdout.write('fetchbuilds: Fetching data for {} '
                    'started builds.'.format(len(projects)))

            for project in projects:

                # A run of the checkpackage command has triggered a
                # build which may have finished by now. Check and
                # save a build data entry if so.

                build = travisclient.get_build_by_id(project.build_id)

                if build and 'state' in build:
                    build_state = build['state']

                    if build_state == 'finished':
                        self.stdout.write(str(project) + ': Build '
                                'finished, saving data ')

                        # Result and status for some builds have been returned
                        # as null from Travis for some reason
                        result = -1
                        if build['result'] != None:
                            result = build['result']

                        status = -1
                        if build['status'] != None:
                            status = build['status']

                        build_data = Build(
                                project = project,
                                build_id = build['id'],
                                package_version = project.package.version,
                                package_created_at = project.package.created_at,
                                result = result,
                                status = status,
                                duration = build['duration'],
                                started_at = parser.parse(build['started_at']),
                                finished_at = parser.parse(build['finished_at']),
                                committer_email = build['committer_email'],
                                committer_name = build['committer_name'],
                                commited_at = parser.parse(build['committed_at']),
                                event_type = build['event_type'],
                                commit = build['commit'],
                                message = build['message'],
                                compare_url = build['compare_url']
                        )
                        try:
                            build_data.save()

                            project.last_build = build_data
                            project.build_started = False
                            project.author_name = build['author_name']
                            project.author_email = build['author_email']

                            repo = travisclient.get_repo(project.username,
                                    project.repository)
                            if repo and 'description' in repo and repo['description']:
                                project.description = repo['description']
                            project.save()
                        except IntegrityError:
                            # TODO: temp fix for missing result from Travis
                            connection._rollback()
                            self.stdout.write(str(project) + ': Error storing build state for project')
                            self.stdout.write(json.dumps(build, sort_keys=True, indent=4))

                            self.stdout.write(traceback.format_exc())

                    else:
                        self.stdout.write(str(project) + ': Build not '
                                'finished, state: ' + build_state)