# Path: malware_crawl/defaults.py
# REQUESTS_SESSIONS = {
#     "api": requests.Session(),
#     "probe": requests.Session()
# }
# 
# Path: malware_crawl/models.py
# class CaptureUrl(models.Model):
#     url_id = models.BigIntegerField(unique=True, primary_key=True)
#     url = models.CharField(max_length=6249)
#     currentstatus = models.CharField(max_length=3, blank=True)
#     lastvisittime = models.CharField(max_length=69, blank=True)
#     operation_id = models.IntegerField(null=True, blank=True)
#     class Meta:
#         db_table = u'url'


from datetime import timedelta
from six.moves import zip, map
from celery import task, current_app
from celery.contrib.batches import Batches
from malware_crawl.defaults import redis_db
from django.conf import settings
from malware_crawl.models import CaptureUrl
from malware_crawl.scan.celery_rpc_client import RevertRpcClient
import time
import cPickle as pickle
            cache_length
        )
    pipe.execute()

    return [total_response[item] for item in items]


@task(base=Batches, flush_every=500, flush_interval=((timedelta(minutes=30).seconds, 0.1)[settings.DEBUG]))
def chpc_malware_scan(requests):
    sig = lambda url: url

    print requests

    reponses = chpc_malware_scan_real(
        (sig(*request.args, **request.kwargs) for request in requests)
    )
    # use mark_as_done to manually return response data
    for response, request in zip(reponses, requests):
        current_app.backend.mark_as_done(request.id, response)


def chpc_malware_scan_real(urls):
    def prepare(url):
        return url

    def request(urls):
        total_response = {}
        if not urls:
            return total_response


# Path: malware_crawl/defaults.py
# REQUESTS_SESSIONS = {
#     "api": requests.Session(),
#     "probe": requests.Session()
# }
# 
# Path: malware_crawl/models.py
# class CaptureUrl(models.Model):
#     url_id = models.BigIntegerField(unique=True, primary_key=True)
#     url = models.CharField(max_length=6249)
#     currentstatus = models.CharField(max_length=3, blank=True)
#     lastvisittime = models.CharField(max_length=69, blank=True)
#     operation_id = models.IntegerField(null=True, blank=True)
#     class Meta:
#         db_table = u'url'


# Path: malware_crawl/scan/capture_hpc.py
from datetime import timedelta
from six.moves import zip, map
from celery import task, current_app
from celery.contrib.batches import Batches
from malware_crawl.defaults import redis_db
from django.conf import settings
from malware_crawl.models import CaptureUrl
from malware_crawl.scan.celery_rpc_client import RevertRpcClient
import time
import cPickle as pickle

            cache_length
        )
    pipe.execute()

    return [total_response[item] for item in items]


@task(base=Batches, flush_every=500, flush_interval=((timedelta(minutes=30).seconds, 0.1)[settings.DEBUG]))
def chpc_malware_scan(requests):
    sig = lambda url: url

    print requests

    reponses = chpc_malware_scan_real(
        (sig(*request.args, **request.kwargs) for request in requests)
    )
    # use mark_as_done to manually return response data
    for response, request in zip(reponses, requests):
        current_app.backend.mark_as_done(request.id, response)


def chpc_malware_scan_real(urls):
    def prepare(url):
        return url

    def request(urls):
        total_response = {}
        if not urls:
            return total_response


        CaptureUrl.objects.using('capture').all().delete()