Beispiel #1
0
 def get(self, request, repo, name):
     try:
         package = self.repository.packages.get(name__iexact=name)
     except ObjectDoesNotExist:
         package = None
         enqueue(fetch_package, self.repository.pk, name)
     return redirect(package)
Beispiel #2
0
    def get(self, request, repo, slug):
        condition = Q()
        for name in get_search_names(slug):
            condition |= Q(name__iexact=name)

        try:
            package = self.repository.packages.get(condition)
        except ObjectDoesNotExist:
            if not self.repository.enable_auto_mirroring:
                raise Http404("Auto mirroring is not enabled")

            enqueue(fetch_package, self.repository.pk, slug)
            return redirect(self.repository.upstream_pypi_url + '/' + slug)

        # Redirect if slug is not an exact match
        if slug != package.name:
            url = reverse('packages:simple_detail',
                          kwargs={
                              'repo': self.repository.slug,
                              'slug': package.name
                          })
            return redirect(url)

        self.object = package
        context = self.get_context_data(object=self.object,
                                        releases=list(package.releases.all()))
        return self.render_to_response(context)
Beispiel #3
0
def update_packages():
    """Update package information for all packages"""
    logging.info('Updated packages')
    for package in models.Package.objects.filter(is_local=False):
        logging.info('Updating package %s', package.name)
        enqueue(fetch_package, package.repository_id, package.name)
    logging.info('Complete')
Beispiel #4
0
def refresh(request, name):
    try:
        package = models.Package.objects.get(name__iexact=name)
    except ObjectDoesNotExist:
        package = None
        enqueue(fetch_package, name)
    return redirect(package)
Beispiel #5
0
    def get(self, request, slug):
        condition = Q()
        for name in get_search_names(slug):
            condition |= Q(name__iexact=name)

        try:
            package = models.Package.objects.get(condition)
        except ObjectDoesNotExist:
            enqueue(fetch_package, slug)
            return redirect('https://pypi.python.org/simple/{}'.format(slug))

        # Redirect if slug is not an exact match
        if slug != package.name:
            url = reverse('packages-simple:simple_detail',
                          kwargs={'slug': package.name})
            return redirect(url)

        self.object = package
        context = self.get_context_data(
            object=self.object,
            releases=list(package.releases.all()))
        return self.render_to_response(context)
Beispiel #6
0
 def get(self, request, repo, name):
     package = get_object_or_404(self.repository.packages,
                                 name__iexact=name)
     enqueue(fetch_package, self.repository.pk, name)
     return redirect(package)
Beispiel #7
0
 def get(self, request, repo, name):
     package = get_object_or_404(self.repository.packages, name__iexact=name)
     enqueue(fetch_package, self.repository.pk, name)
     return redirect(package)