Esempio n. 1
0
    def execute(my):
        assert my.snapshot
        assert my.sobject

        # add some additional options
        my.set_option("snapshot_code", my.snapshot.get_code() )
        my.set_option("render_dir", my.get_render_dir() )

        input_path = my.get_input_path()
        my.set_option("input_path", input_path)

        # handle the policy if it exists
        policy = my.render_package.get_policy()
        if policy:
            width = policy.get_value("width")
            height = policy.get_value("height")
            frame_by = policy.get_value("frame_by")
            extra_settings = policy.get_value("extra_settings")

            my.set_option("resolution", "%sx%s" % (width, height))

            my.set_option("width", width)
            my.set_option("height", height)
            my.set_option("frame_by", frame_by)
            my.set_option("extra_settings", extra_settings)
            





        # get some information from the render context
        search_type = my.sobject.get_search_type_obj()
        description = "Render %s: %s" % (search_type.get_title(),my.sobject.get_code())

        # create queue in tactic related to this submission
        if not my.queue:
            my.queue = Queue.create(my.sobject, "render", "9999", description)
        else:
            my.queue.set_sobject_value(my.sobject)
            my.queue.set_value('login', Environment.get_user_name())
            # have to make sure it is committed to get a queue_id
            if my.queue.get_id() == -1:
                my.queue.commit()


        # submit the job to the dispatcher
        dispatcher_id = my.submit()

        # store the dispatcher id in the queue object
        my.queue.set_value("dispatcher_id", dispatcher_id)
        my.queue.commit()
Esempio n. 2
0
    def execute(my):
        assert my.snapshot
        assert my.sobject

        # add some additional options
        my.set_option("snapshot_code", my.snapshot.get_code())
        my.set_option("render_dir", my.get_render_dir())

        input_path = my.get_input_path()
        my.set_option("input_path", input_path)

        # handle the policy if it exists
        policy = my.render_package.get_policy()
        if policy:
            width = policy.get_value("width")
            height = policy.get_value("height")
            frame_by = policy.get_value("frame_by")
            extra_settings = policy.get_value("extra_settings")

            my.set_option("resolution", "%sx%s" % (width, height))

            my.set_option("width", width)
            my.set_option("height", height)
            my.set_option("frame_by", frame_by)
            my.set_option("extra_settings", extra_settings)

        # get some information from the render context
        search_type = my.sobject.get_search_type_obj()
        description = "Render %s: %s" % (search_type.get_title(),
                                         my.sobject.get_code())

        # create queue in tactic related to this submission
        if not my.queue:
            my.queue = Queue.create(my.sobject, "render", "9999", description)
        else:
            my.queue.set_sobject_value(my.sobject)
            my.queue.set_value('login', Environment.get_user_name())
            # have to make sure it is committed to get a queue_id
            if my.queue.get_id() == -1:
                my.queue.commit()

        # submit the job to the dispatcher
        dispatcher_id = my.submit()

        # store the dispatcher id in the queue object
        my.queue.set_value("dispatcher_id", dispatcher_id)
        my.queue.commit()
Esempio n. 3
0
    def get_queue(my, ticket):
        execute_xml = "<execute/>"
        try:
            my.init(ticket)

            from pyasm.prod.queue import Queue
            job = Queue.get_next_job()
            if job:
                job.execute()

                # need to get the execute xml
                command = job.get_command()
                execute_xml = command.get_execute_xml()

        finally:
            DbContainer.close_all()

        return execute_xml
Esempio n. 4
0
    def get_next_job(my):
        from pyasm.prod.queue import Queue
        import random
        import time
        interval = 0.2
        time.sleep(interval)
        job_search_type = my.get_job_search_type()
        servers_tried = []

        job = None
        while 1:
            my.servers = Container.get("TransactionQueueServers")
            if my.servers == None:
                trigger = TransactionQueueServersTrigger()
                trigger.execute()
                my.servers = Container.get("TransactionQueueServers")


            # use a random load balancer.  This algorithm is pretty
            # inefficient, but will only be an issue if there are lots
            # of servers
            num_servers = len(my.servers)
            if num_servers == 0:
                break


            server_index = random.randint(0, len(my.servers)-1)
            if server_index in servers_tried:
                continue

            server_code = my.servers[server_index].get_code()
            #print "server_code: ", server_code
            job = Queue.get_job(job_search_type=job_search_type, server_code=server_code)
            if job:
                break

            servers_tried.append(server_index)
            if len(servers_tried) == len(my.servers):
                break

        return job
Esempio n. 5
0
    def set_args(my, ticket, queue_id):

        my.ticket = ticket


        # get the necessary data
        queue = Queue.get_by_id(queue_id)
        #data = queue.get_xml_value("data")
        data = queue.get_xml_value("serialized")
        search_key = data.get_value("data/search_key")

        my.sobject = Search.get_by_search_key(search_key)
        if not my.sobject:
            raise Exception("SObject with search_key: %s does not exist" % search_key)

        snapshot_code = data.get_value("data/snapshot_code")
        my.snapshot = Snapshot.get_by_code(snapshot_code)

        my.file_range = data.get_value("data/file_range")
        my.session = "<session/>"

        my.pattern = data.get_value("data/pattern")
Esempio n. 6
0
 def get_next_job(my):
     from pyasm.prod.queue import Queue
     return Queue.get_next_job();