def execute(self):
    class_names = self.kwargs.get('class_names')
    attrs_list = self.kwargs.get('attrs_list')
    kwargs_list = self.kwargs.get('kwargs_list')
    save_state = self.kwargs.get('save_state')
    xml = Xml()
    xml.create_doc('config')
    root = xml.get_root_node()
    view = xml.create_element('tab')
    xml.append_child(root, view)
    for (class_name, attrs, kwargs) in zip(class_names, attrs_list, kwargs_list):
        element = xml.create_element('element')
        xml.append_child(view, element)
        for (key, value) in attrs.items():
            xml.set_attribute(element, key, value)
        display = xml.create_element('display')
        xml.append_child(element, display)
        if class_name.startswith('$'):
            from pyasm.common import jsonloads
            key = class_name
            key = key.lstrip('$')
            tmp_dir = Environment.get_tmp_dir(include_ticket=True)
            path = ('%s/%s_key_%s.txt' % (tmp_dir, 'widget', key))
            if (not os.path.exists(path)):
                print(('ERROR: %s path [%s] not found' % ('widget', path)))
                raise Exception('widget key not valid')
            f = open(path, 'r')
            data = f.read()
            f.close()
            data = jsonloads(data)
            class_name = data.get('method')
        xml.set_attribute(display, 'class', class_name)
        for (key, value) in kwargs.items():
            if (key == 'count'):
                xml.set_attribute(element, key, value)
            else:
                attr = xml.create_text_element(key, value)
                xml.append_child(display, attr)
    xml_string = xml.to_string()
    WidgetSettings.set_value_by_key(save_state, xml_string)
def execute(self):
    class_names = self.kwargs.get('class_names')
    attrs_list = self.kwargs.get('attrs_list')
    kwargs_list = self.kwargs.get('kwargs_list')
    save_state = self.kwargs.get('save_state')
    xml = Xml()
    xml.create_doc('config')
    root = xml.get_root_node()
    view = xml.create_element('tab')
    xml.append_child(root, view)
    for (class_name, attrs, kwargs) in zip(class_names, attrs_list, kwargs_list):
        element = xml.create_element('element')
        xml.append_child(view, element)
        for (key, value) in attrs.items():
            xml.set_attribute(element, key, value)
        display = xml.create_element('display')
        xml.append_child(element, display)
        if class_name.startswith('$'):
            from pyasm.common import jsonloads
            key = class_name
            key = key.lstrip('$')
            tmp_dir = Environment.get_tmp_dir(include_ticket=True)
            path = ('%s/%s_key_%s.txt' % (tmp_dir, 'widget', key))
            if (not os.path.exists(path)):
                print(('ERROR: %s path [%s] not found' % ('widget', path)))
                raise Exception('widget key not valid')
            f = open(path, 'r')
            data = f.read()
            f.close()
            data = jsonloads(data)
            class_name = data.get('method')
        xml.set_attribute(display, 'class', class_name)
        for (key, value) in kwargs.items():
            if (key == 'count'):
                xml.set_attribute(element, key, value)
            else:
                attr = xml.create_text_element(key, value)
                xml.append_child(display, attr)
    xml_string = xml.to_string()
    WidgetSettings.set_value_by_key(save_state, xml_string)