Exemplo n.º 1
0
def generateJobs(producer, EntityType, eList, tag = None):

    # build jobs of up to 64 entries
    jobCount = 0
    jList = [ ]
    for i in range(len(eList)):
        # append the entity
        jList.append( [ EntityType, eList[i] ] )

        # if max number of entities reached, send job
        if len(jList) == maxEntities:

            # create the job
            job = jobs.encode(jobs.generate(jList, tag))

            # get an item, set content and make it ready
            item = producer.item()
            item.content = job
            producer.ready(item)
            jobCount += 1

            # new list
            jList = [ ]

    # if list not empty, send job
    if len(jList) > 0:

        # create the job
        job = jobs.encode(jobs.generate(jList, tag))

        # get an item, set content and make it ready
        item = producer.item()
        item.content = job
        producer.ready(item)
        jobCount += 1

    return jobCount
Exemplo n.º 2
0
def cmd_cache(arguments):

    # create an exit job
    job = jobs.encode(jobs.cache())

    # get a producer
    producer = getProducer()

    # get an item, set content and make it ready
    item = producer.item()
    item.content = job
    producer.ready(item)

    print "Cache command put in queue"

    return 0
Exemplo n.º 3
0
def cmd_sitemap(arguments):
    """List the job queue"""

    # create a sitemap job
    job = jobs.encode(jobs.sitemap())

    # get a producer
    producer = getProducer()

    # get an item, set content and make it ready
    item = producer.item()
    item.content = job
    producer.ready(item)

    print "Sitemap command put in queue"

    return 0