예제 #1
0
    def test_oga(self):
        import redis
        rs1 = redis.Redis(host="localhost", db=0)
        rs1.flushdb()
        
        res = tasks.oga('http://opengameart.org/content/fieldstone-fireplace')
        job_id = res.id
        
        print 'STARTING', res.id

        
        while True:
            stats, ready = tasks.collect_stats(job_id)
            print stats, ready, tasks.has_completed(job_id)
            if ready:
                job = AsyncResult(job_id)
                print 'test_oga1:', job.info, job.state, job.ready(), job.successful(), job.result
                break

        print tasks.collect_stats(job_id)        
        if job.successful():
            print 'test_oga2:', [x.result for x in job.result]
        else:
            print 'test_oga3: FAILED'
            
        descriptions = []
        for result in job.result:
            descriptions.extend(result.get().values())
        group = tasks.generate_previews_for_filedescriptions(descriptions)
        group_id = group.id
        

        while True:
            stats, ready = tasks.collect_stats_transcoding(group_id)
            print stats, ready
            if ready:
                break

        assert True
예제 #2
0
def analyze(request):
    url = request.GET.get('url', False)
    if not url or not is_oga_url(url):
        return HttpResponse('Not a valid url', status=400)

    job = schedule(url, lambda: tasks.oga(url, task_id=url), request)
    stats, ready = tasks.collect_stats(job.id)
    
    if ready:
        job = AsyncResult(job.id)        
        return HttpResponse(json.dumps(stats, indent=4), content_type="application/json")
    else:
        return HttpResponse(json.dumps(stats, indent=4), content_type="application/json")