def run(self):
     writeshared.set_object(self.target_object)
     self.add_import_statements()
     self.add_assign_object_statement()
     self.add_getter_statement()
     self.add_delete_statement()
     self.run_command()
     self.result = readshared.get_result()
Example #2
0
 def run(self):
     writeshared.set_object(self.target_object)
     self.add_import_statements()
     self.add_assign_object_statement()
     self.add_getter_statement()
     self.add_delete_statement()
     self.run_command()
     self.result = readshared.get_result()
    def __get_command (self, property, value, object):
        command = ''        
        # Execute each setter with his value        
        for setter in map(None, property["setters"]):
            command_name = setter["name"]            
            command = command + "import writeshared;import readshared;"
            command = command + "object = readshared.get_object();"
            command = command + "result = object." + command_name.lower() + "("
            has_params = False
            p_count = 0
            for param in property["params"]:
                has_params = True
                if param["type"] == 's':
                    # convert '\' to '\\' for correct formating, 
                    # because python server formats it automatically
                    slashes = value[p_count]
                    slashes = slashes.replace('\\','\\\\')
                    command = command + "'" + str(slashes) + "',"
                elif param["type"] == 'o':
                    obj_type = self.get_object_type(value[p_count])
                    if obj_type == "entity":
                        entity_id = value[p_count].getid()
                        get_entity_string = "servers.get_entity_object_server()."\
                                                        "getentityobject(%s)," % str(entity_id)
                        command = command + get_entity_string
                    elif obj_type == "nroot" or "entityclass":
                        full_name = value[p_count].getfullname()
                        command = command + "lookup('" + str(full_name) +"'),"
                    else:
                        # The share module for getting the nobject
                        writeshared.set_object(value[p_count])
                        command += "readshared.get_object(),"
                elif self.is_vector_or_quaternion_type( param["type"] ):
                    if isinstance(value[p_count], list):
                        for each_value in value[p_count]:
                            command = command + str(each_value) + ","
                    else:
                        for each_value in value:
                            command = command + str(each_value) + ","
                else:
                    command = command + str(value[p_count]) + ","
                p_count += 1
            if has_params:
                command = command[:-1]
            command += ");"
            command = command + "writeshared.set_result(result);del object;"

        return command
Example #4
0
    def __get_command(self, property, value, object):
        command = ''
        # Execute each setter with his value
        for setter in map(None, property["setters"]):
            command_name = setter["name"]
            command = command + "import writeshared;import readshared;"
            command = command + "object = readshared.get_object();"
            command = command + "result = object." + command_name.lower() + "("
            has_params = False
            p_count = 0
            for param in property["params"]:
                has_params = True
                if param["type"] == 's':
                    # convert '\' to '\\' for correct formating,
                    # because python server formats it automatically
                    slashes = value[p_count]
                    slashes = slashes.replace('\\', '\\\\')
                    command = command + "'" + str(slashes) + "',"
                elif param["type"] == 'o':
                    obj_type = self.get_object_type(value[p_count])
                    if obj_type == "entity":
                        entity_id = value[p_count].getid()
                        get_entity_string = "servers.get_entity_object_server()."\
                                                        "getentityobject(%s)," % str(entity_id)
                        command = command + get_entity_string
                    elif obj_type == "nroot" or "entityclass":
                        full_name = value[p_count].getfullname()
                        command = command + "lookup('" + str(full_name) + "'),"
                    else:
                        # The share module for getting the nobject
                        writeshared.set_object(value[p_count])
                        command += "readshared.get_object(),"
                elif self.is_vector_or_quaternion_type(param["type"]):
                    if isinstance(value[p_count], list):
                        for each_value in value[p_count]:
                            command = command + str(each_value) + ","
                    else:
                        for each_value in value:
                            command = command + str(each_value) + ","
                else:
                    command = command + str(value[p_count]) + ","
                p_count += 1
            if has_params:
                command = command[:-1]
            command += ");"
            command = command + "writeshared.set_result(result);del object;"

        return command
    def __execute_property (self, property, value, object, undo=False):
        writeshared.set_object(object)
        # Execute each setter with his value        
        if value != []:
            command = self.__get_command(property, value, object)
            if undo == False:                
                # Run the command
                servers.get_python_server().run(str(command))
            else:
                init_value = self.init_values[property["name"]]["value"]
                undo_cmd = self.__get_command(property, init_value[0], object)
                servers.get_command_server().newcommand(str(command), 
                                                    str(undo_cmd))

            self.values[property['name']]['value'] = [readshared.get_result()]
            object.setobjectdirty( True )

        return readshared.get_result()
Example #6
0
    def __execute_property(self, property, value, object, undo=False):
        writeshared.set_object(object)
        # Execute each setter with his value
        if value != []:
            command = self.__get_command(property, value, object)
            if undo == False:
                # Run the command
                servers.get_python_server().run(str(command))
            else:
                init_value = self.init_values[property["name"]]["value"]
                undo_cmd = self.__get_command(property, init_value[0], object)
                servers.get_command_server().newcommand(
                    str(command), str(undo_cmd))

            self.values[property['name']]['value'] = [readshared.get_result()]
            object.setobjectdirty(True)

        return readshared.get_result()