Example #1
0
def fetch_index():
    # clean out the old packages so we don't need to do
    # expensive get_or_create calls each time
    # but make sure we leave private packages intact
    Pkg.objects.filter(private=False).delete()
    
    packages = _get_client().list_packages()
    pkg_list = []
    for package_name in packages:
        # TODO: this needs to be broken up when using sqlite - see
        # https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.bulk_create
        pkg_list.append(Pkg(name=package_name))
    Pkg.objects.bulk_create(pkg_list)
        
    state = get_mirror_state()
    state.index_fetch_status = FetchStatus.COMPLETE
    state.save()
 
    fetch_releases.delay()
Example #2
0
 def process_request(self, request):
     if not any(map(request.path.startswith, ('/admin/', '/fetchstatus/'))):
         if get_mirror_state().index_fetch_status != FetchStatus.COMPLETE:
             return render(request, 'please_wait.html')
Example #3
0
 def is_due(self):
     if self.name == 'pihub.packages.tasks.check_fetch_index':
         return get_mirror_state().index_fetch_status == FetchStatus.NOT_STARTED, 0
     return super(ImmediateFirstEntry, self).is_due()
Example #4
0
def check_fetch_index():
    state = get_mirror_state()
    state.index_fetch_status = FetchStatus.FETCHING
    state.save()
    fetch_index.delay()
Example #5
0
def fetch_status_index(request):
    fetched = get_mirror_state().index_fetch_status == FetchStatus.COMPLETE
    return {'fetched': fetched}