Esempio n. 1
0
def main():

	from class_macro import Macros
	from widget_plugins import WidgetPlugins
	from widget_macro import WidgetMacros
	from class_plugins import Plugins

	plugin_id = request.shared_variables["plugin_id"]
	plugin = Plugins.get_by_id(plugin_id)

	macros = Macros()
	macros.name 		= "config"
	macros.class_name	= ""
	macros.timer_guid 	= ""
	macros.is_button_macros = "1"
	macros.on_board 	= "1"
	macros.description 	= "config macro"
	macros.plugin_guid = plugin.guid
	macros.save()

	plugin = Plugins.get_by_id(plugin_id)
	macros = plugin.get_macros()

	widget_macros = WidgetMacros()
	widget_macros.set_data(macros)
	widget_macros.render(self.datatable_macros)

	self.button_create_config.visible = "0"
	self.button_config.visible = "1"
Esempio n. 2
0
def main():

    from class_macro import Macros
    from widget_macro import WidgetMacros
    from class_plugins import Plugins

    macros_id = request.shared_variables["macro_id"]
    plugin_id = request.shared_variables["plugin_id"]
    if macros_id:
        macros = Macros.get_by_id(macros_id)
        macros.delete()

    plugin = Plugins.get_by_id(plugin_id)
    macros = plugin.get_macros()
    config_is_exist = False
    for m in macros:
        if m.name == "config":
            config_is_exist = True

    if config_is_exist == True:
        self.button_config.visible = "1"
        self.button_create_config.visible = "0"
    else:
        self.button_config.visible = "0"
        self.button_create_config.visible = "1"

    plugin = Plugins.get_by_id(plugin_id)
    macros = plugin.get_macros()

    widget_macros = WidgetMacros()
    widget_macros.set_data(macros)
    widget_macros.render(self.datatable_macros)

    self.dialog_delete_macro.action("hide", [])
    response.shared_variables["macro_id"] = ""
Esempio n. 3
0
def main():

	from class_custom_event import CustomEvent
	from widget_custom_event import WidgetCustomEvent
	from class_plugins import Plugins

	name = request.arguments.get("formtext_name", "")
	id = request.arguments.get("formtext_id", "")
	plugin_id = request.shared_variables["plugin_id"]
	plugin = Plugins.get_by_id(plugin_id)
	if name:
		custom_event = CustomEvent.get_by_id(id) if id else CustomEvent()
		custom_event.name = name
		custom_event.plugin_guid = plugin.guid
		custom_event.save()
	else:
		self.growl.action("show", ["Error", "Fill custom event name"])



	custom_event_list = plugin.get_custom_event()
	widget_custom_event = WidgetCustomEvent()
	widget_custom_event.set_data(custom_event_list)
	widget_custom_event.render(self.datatable_custom_event)
	self.dialog_add_custom_event.action("hide", [])
def main():

	from class_plugins import Plugins
	from widget_plugins import WidgetPlugins
	from VEE_resources import delete_plugin_dir

	if "plugin_id" in session and session["plugin_id"]:
		plugin = Plugins.get_by_id(session.get("plugin_id"))
		delete_plugin_dir(plugin.guid)
		plugin.delete()

		widget_plugins = WidgetPlugins()
		plugins_obj = Plugins.get_all()
		widget_plugins.set_data(plugins_obj)
		widget_plugins.render(self.datatable_plugin)

		self.dialog_uninstall.action("hide", [])
Esempio n. 5
0
def main():

    from class_plugins import Plugins
    from class_macro import Macros
    from VEE_resources import create_plugin_dir

    def invoke_dispather(macros):

        from VEE_vmacro_dispatcher import InvokeDispatcher
        from VEE_std_lib import v_currentpage

        invoke_disp = InvokeDispatcher()
        invoke_disp.page = self
        invoke_disp.growl = self.growl
        invoke_disp.xmldialog = self.xmldialog
        invoke_disp.macros = macros

        current_page = v_currentpage()
        current_page.page_name = self.name

        invoke_disp.current_page = current_page
        invoke_disp.run()

    plugin_id = session["plugin_id"] = request.arguments.get("keyField", "")
    cell_name = request.arguments.get("headerData", "")

    if plugin_id:
        plugin = Plugins.get_by_id(plugin_id)

        if cell_name and plugin:

            if cell_name == "Update":
                self.dialog_update_plugin.text_description.action(
                    "setText", ["Plugin to update - %s" % (plugin.name)])
                self.dialog_update_plugin.form.formtext_pluginid.action(
                    "setValue", [plugin.id])
                self.dialog_update_plugin.action("show", [""])

            elif cell_name == "Export":
                self.action("goTo", ["/plugins?op=export"])

            elif cell_name == "Open":
                create_plugin_dir(plugin.guid)
                self.action("goTo", ["/plugin_details?id=%s" % plugin_id])

            elif cell_name == "Delete":
                session["plugin_id"] = plugin_id
                self.dialog_uninstall.action("show", [])

            elif cell_name == "MD5":
                self.dialog_md5.text_md5.action("setText", [plugin.get_md5()])
                self.dialog_md5.action("show", [])

            elif cell_name == "Config":
                from class_macro import Macros
                macros = Macros.get_config_macro(plugin.guid)
                if macros:
                    invoke_dispather(macros)
def main():

	from class_plugins import Plugins

	plugin_id = request.shared_variables[ "plugin_id" ]
	plugin = Plugins.get_by_id( plugin_id )
	if plugin:
		from class_macro import Macros
		macros = Macros.get_config_macro( plugin.guid )
		if macros:
			invoke_dispather( macros )
def main():

    from class_plugins import Plugins
    plugin_id = request.shared_variables["plugin_id"]
    if plugin_id:
        plugin = Plugins.get_by_id(plugin_id)

        self.dialog_update_plugin.text_description.action(
            "setText", ["Plugin to update - %s" % (plugin.name)])
        self.dialog_update_plugin.form.formtext_pluginid.action(
            "setValue", [plugin.id])
    def plugins_dict(self):
        from class_plugins import Plugins
        import localization, collections

        lang = localization.get_lang()

        data = collections.OrderedDict()
        data["all"] = lang.get("log_all_messages", "All messages")

        for plugin in Plugins.get_all():
            data["p" + plugin.guid] = plugin.name
            for macros in plugin.get_macros():
                data["m" + macros.guid] = "--" + macros.name

        return data
def main():

    from class_plugins import Plugins

    plugin_id = request.shared_variables["plugin_id"]
    if plugin_id:

        plugin = Plugins.get_by_id(plugin_id)

        #self.dialog_create.action("setTitle", ["Edit plugin"])
        self.dialog_create.form_update.formtext_id.value = plugin_id
        self.dialog_create.form_update.formtext_name.value = plugin.name
        self.dialog_create.form_update.formtext_author.value = plugin.author
        self.dialog_create.form_update.formtextarea_description.value = plugin.description
        self.dialog_create.form_update.formtext_version.value = plugin.version
        self.dialog_create.form_update.hpt.htmlcode = "<img src='/get_image?id=%s'/>" % plugin.picture if plugin.picture else ""
def main():

    from class_plugins import Plugins
    from VEE_resources import delete_plugin_dir

    plugin_id = request.shared_variables["plugin_id"]

    if plugin_id:
        plugin = Plugins.get_by_id(plugin_id)
        delete_plugin_dir(plugin.guid)
        plugin.delete()

        self.dialog_uninstall.action("hide", [])
        self.action("goTo", ["/plugins.vdom"])

    response.shared_variables["plugin_id"]
Esempio n. 11
0
def main():

    from widget_plugin_db import WidgetPluginDB
    from class_plugins import Plugins
    from VEE_sqlite3 import DatabaseManager

    plugin_id = request.shared_variables["plugin_id"]
    db_name = request.shared_variables["db_name"]

    if plugin_id and db_name:
        plugin = Plugins.get_by_id(int(plugin_id))
        DatabaseManager(plugin.guid).delete_db(db_name)

        widget_db = WidgetPluginDB()
        widget_db.set_data(DatabaseManager(plugin.guid).databaselist)
        widget_db.render(self.datatable_db)

    self.dialog_delete_db.action("hide", [])
    response.shared_variables["db_name"] = ""
Esempio n. 12
0
def main():

	from widget_resource import WidgetResource
	from class_plugins import Plugins
	from VEE_resources import ResourceFolderManager

	plugin_id = request.shared_variables["plugin_id"]
	res_name = request.shared_variables["res_name"]
	if plugin_id and res_name:
		plugin = Plugins.get_by_id(int(plugin_id))
		ResourceFolderManager(plugin.guid).delete_res(res_name)

		widget_resource = WidgetResource()
		widget_resource.set_data(ResourceFolderManager(plugin.guid).resourcelist, plugin.guid)
		widget_resource.render(self.datatable_resource)


	self.dialog_delete_resource.action("hide", [])
	response.shared_variables["res_name"] = ""
Esempio n. 13
0
def main():

    from class_timer import Timer
    from widget_plugins import WidgetPlugins
    from widget_timer import WidgetTimer
    from class_plugins import Plugins
    plugin_id = request.shared_variables["plugin_id"]
    timer_id = request.shared_variables["timer_id"]
    if timer_id:
        timer = Timer.get_by_id(timer_id)
        timer.delete()

    plugin = Plugins.get_by_id(plugin_id)
    timer = plugin.get_timer()

    widget_timer = WidgetTimer()
    widget_timer.set_data(timer)
    widget_timer.render(self.datatable_timer)

    self.dialog_delete_timer.action("hide", [])
    response.shared_variables["timer_id"]
Esempio n. 14
0
    def render(self, datatable, dialog):

        plugin = Plugins.get_by_guid(self.plugin_guid)
        if not plugin:
            raise Exception( "Plugin with GUID={guid} doesn't exists".format( \
                   guid = self.plugin_guid ) )

        data = []
        for macro in plugin.get_macros():
            if  macro.on_board != "1" and \
              macro.is_button_macros == "1" and \
              macro.page == self.page_name and \
              macro.name != CONFIG_MACRO_NAME:

                data.append(
                    (macro.guid, "<img src='/get_image?id=%s'/>" %
                     macro.macros_picture if macro.macros_picture else "",
                     macro.name))

        datatable.data = json.dumps(data)
        dialog.title = plugin.name
Esempio n. 15
0
def main():

    from class_timer import Timer
    from class_custom_event import CustomEvent
    from class_macro import Macros
    import json, localization
    from class_plugins import Plugins
    from config import config
    from VEE_events import event_map

    lang = localization.get_lang()

    macros_id = request.shared_variables["macro_id"]
    plugin_id = request.shared_variables["plugin_id"]
    plugin = Plugins.get_by_id(plugin_id)

    macro_type = request.arguments.get("itemValue", Macros.MacrosType.UNKNOWN)

    def setup_event_type_controls():
        self.dialog_create_macro.form_macro.container_back.formlist_location.visible = "0"
        self.dialog_create_macro.form_macro.container_back.text_location.visible = "0"
        self.dialog_create_macro.form_macro.container_back.formlist_event.visible = "1"
        self.dialog_create_macro.form_macro.container_back.text_event.visible = "1"
        self.dialog_create_macro.form_macro.container_back.formlist_page.visible = "0"
        self.dialog_create_macro.form_macro.container_back.text_timer.visible = "0"

        event_dict = {}
        for event in event_map:
            event_dict[event] = lang[event_map[event].__name__]

        for timer in Timer.get_timer_by_plugin_guid(plugin.guid):
            event_dict[timer.guid] = timer.name

        for cevent in CustomEvent.get_custom_event_by_plugin_guid(plugin.guid):
            event_dict[cevent.guid] = cevent.name

        self.dialog_create_macro.form_macro.container_back.formlist_event.value = json.dumps(
            event_dict)

    def setup_button_type_controls():
        self.dialog_create_macro.form_macro.container_back.formlist_page.selectedvalue = config[
            "plugin_page_dict"].keys()[0]
        self.dialog_create_macro.form_macro.container_back.formlist_page.value = json.dumps(
            config["plugin_page_dict"])
        self.dialog_create_macro.form_macro.container_back.formlist_location.visible = "1"
        self.dialog_create_macro.form_macro.container_back.text_location.visible = "1"
        self.dialog_create_macro.form_macro.container_back.formlist_event.visible = "0"
        self.dialog_create_macro.form_macro.container_back.text_event.visible = "0"
        self.dialog_create_macro.form_macro.container_back.formlist_location.value = json.dumps(
            {
                "1": "On panel",
                "2": "In plugin menu"
            })

    def setup_library_type_controls():
        self.dialog_create_macro.form_macro.container_back.formlist_page.visible = "0"
        self.dialog_create_macro.form_macro.container_back.formlist_location.visible = "0"
        self.dialog_create_macro.form_macro.container_back.text_location.visible = "0"
        self.dialog_create_macro.form_macro.container_back.formlist_event.visible = "0"
        self.dialog_create_macro.form_macro.container_back.text_event.visible = "0"
        self.dialog_create_macro.form_macro.container_back.text_timer.visible = "0"

    if macros_id and macro_type == Macros.MacrosType.UNKNOWN:

        macros = Macros.get_by_id(macros_id)

        self.dialog_create_macro.form_macro.formtext_id.value = macros_id
        self.dialog_create_macro.form_macro.formtext_name.value = macros.name
        self.dialog_create_macro.form_macro.formtextarea_description.value = macros.description
        macro_type = macros.type

        if macros.type == Macros.MacrosType.EVENT:
            setup_event_type_controls()

            if macros.timer_guid:
                self.dialog_create_macro.form_macro.container_back.formlist_event.selectedvalue = macros.timer_guid
            elif macros.custom_event_guid:
                self.dialog_create_macro.form_macro.container_back.formlist_event.selectedvalue = macros.custom_event_guid
            elif macros.class_name:
                for event in event_map:
                    if event_map[event].__name__ == macros.class_name:
                        self.dialog_create_macro.form_macro.container_back.formlist_event.selectedvalue = event
                        break

        elif macros.type == Macros.MacrosType.BUTTON:
            setup_button_type_controls()
            self.dialog_create_macro.form_macro.container_back.formlist_location.selectedvalue = "1" if macros.on_board == "1" else "2"
            self.dialog_create_macro.form_macro.container_back.formlist_page.selectedvalue = macros.page

        else:
            setup_library_type_controls()

    self.dialog_create_macro.form_macro.container_back.formlist_type.value = json.dumps(
        {
            Macros.MacrosType.EVENT: "Event macro",
            Macros.MacrosType.BUTTON: "Button macro",
            Macros.MacrosType.LIBRARY: "Library"
        })

    if macro_type == Macros.MacrosType.UNKNOWN:
        macro_type = Macros.MacrosType.EVENT

    self.dialog_create_macro.form_macro.container_back.formlist_type.selectedvalue = macro_type

    if macro_type == Macros.MacrosType.BUTTON:
        setup_button_type_controls()

    elif macro_type in Macros.MacrosType.EVENT:
        setup_event_type_controls()

    else:
        setup_library_type_controls()
Esempio n. 16
0
            widget_db.set_data(DatabaseManager(plugin.guid).databaselist)
            widget_db.render(self.datatable_db)

            widget_resource = WidgetResource()
            widget_resource.set_data(
                ResourceFolderManager(plugin.guid).resourcelist, plugin.guid)
            widget_resource.render(self.datatable_resource)

            self.dialog_add_timer.action("hide", [])
        except Exception, ex:
            self.growl.title = lang["error"]
            self.growl.text = str(ex)
            self.growl.visible = "1"

    if "formbutton_save_plugin" in request.arguments:
        plugin = Plugins.get_by_id(request.arguments.get("formtext_id", ""))
        if plugin:
            plugin.name = request.arguments.get("formtext_name", "")
            plugin.author = request.arguments.get("formtext_author", "")
            plugin.description = request.arguments.get(
                "formtextarea_description", "")
            plugin.version = request.arguments.get("formtext_version", "")
            #raise Exception(file.name)
            if "uploader" in request.arguments:
                file = request.arguments.get("uploader", "", castto=Attachment)
                if file:
                    plugin.picture = str(uuid4())
                    application.storage.write(plugin.picture,
                                              file.handler.read())

            plugin.save()
def check():
    from VEE_tools import compile, VScriptComlipationError, PythonCompilationError
    try:
        compile(source)
        return "Passed well."
        self.growl.action('show', ["Message", u"No errors in code."])
    except VScriptComlipationError as error:
        return u"VScript Compilation Error (Line {line}): {msg}".format(
            line=error.line, msg=error.message)
    except PythonCompilationError as error:
        return u"Python Compilation Error: {msg}".format(msg=error.message)


macro_id = request.shared_variables["macro_id"]
macro = Macros.get_by_id(macro_id)
plugin = Plugins.get_by_guid(macro.plugin_guid)
if plugin and macro:
    source = self.form_macros.codeeditor_macros_body.value = request.arguments.get(
        "codeeditor_macros_body", "")
    macro.code = source
    macro.save()
    result = check()
    self.growl.action(
        'show',
        ["Message", u"Your work is saved! Compilnig: {0}".format(result)])

else:
    self.growl.action('show', [
        "Error =(", u"Can't save code macro. Please, try to reload the page."
    ])
Esempio n. 18
0
def main():

    from class_macro import Macros
    from class_plugins import Plugins
    import cgi, localization

    lang = localization.get_lang()

    macros_id = request.arguments.get("id")
    response.shared_variables["macro_id"] = macros_id
    plugin = ""
    if macros_id:
        macros = Macros.get_by_id(macros_id)
        plugin = Plugins.get_by_guid(macros.plugin_guid)
        if plugin.protected:
            response.redirect("/plugins.vdom")
        self.form_macros.codeeditor_macros_body.value = macros.code if macros.code else ""

    if "formbutton_apply" in request.arguments:
        if plugin:
            source = self.form_macros.codeeditor_macros_body.value = request.arguments.get(
                "codeeditor_macros_body", "")
            macros = Macros.get_by_id(macros_id) if macros_id else Macros()
            macros.code = source
            macros.save()
            response.redirect("/plugin_details?id=" + str(plugin.id))
        else:
            self.growl.title = lang["error"]
            self.growl.text = "Unknown macro"
            self.growl.visible = "1"

    elif "formbutton_check" in request.arguments:
        if macros_id:
            source = self.form_macros.codeeditor_macros_body.value = request.arguments.get(
                "codeeditor_macros_body", "")
            if source:

                from VEE_tools import compile, VScriptComlipationError, PythonCompilationError
                try:
                    compile(source)
                except VScriptComlipationError as error:
                    self.growl.title = lang["error"]
                    self.growl.text = u"VScript Compilation Error (Line {line}): {msg}".format(
                        line=error.line, msg=error.message)
                    self.growl.visible = "1"

                except PythonCompilationError as error:
                    self.growl.title = lang["error"]
                    self.growl.text = u"Python Compilation Error: {msg}".format(
                        msg=error.message)
                    self.growl.visible = "1"

            else:
                self.growl.title = lang["error"]
                self.growl.text = lang["type_macros_code_error"]
                self.growl.visible = "1"

        else:
            self.growl.title = lang["error"]
            self.growl.text = lang["fill_macros_fields_error"]
            self.growl.visible = "1"

    elif "formbutton_cancel" in request.arguments:
        response.redirect("/plugin_details?id=" +
                          str(plugin.id)) if plugin else response.redirect(
                              "/plugins")
Esempio n. 19
0
def main():

    import json, localization, base64
    from xml.dom.minidom import parseString
    from class_plugins import Plugins
    from class_xml_macro import XMLMacros
    from class_xml_timer import XMLTimer
    from class_xml_custom_event import XMLCustomEvent
    from class_xml_plugin import XMLPlugin
    from class_xml_plugin_db import XMLPluginDB
    from class_xml_resource import XMLResource
    from utils.uuid import uuid4
    from widget_localization import LocalizationWidget
    from widget_plugins import WidgetPlugins
    from widget_macro import WidgetMacros
    from widget_timer import WidgetTimer
    from widget_custom_event import WidgetCustomEvent
    from widget_plugin_db import WidgetPluginDB
    from widget_resource import WidgetResource
    from class_macro import Macros
    from class_timer import Timer
    from class_custom_event import CustomEvent
    from VEE_sqlite3 import DatabaseManager
    from VEE_resources import ResourceFolderManager

    lang = localization.get_lang()

    if "id" in request.arguments:
        try:
            plugin = Plugins.get_by_id(int(request.arguments.get("id", 0)))
            if plugin.protected:
                response.redirect("/plugins.vdom")
            macros = plugin.get_macros()
            timer_list = plugin.get_timer()
            custom_event_list = plugin.get_custom_event()

            config_is_exist = False
            for m in macros:
                if m.name == "config":
                    config_is_exist = True

            if config_is_exist == True:
                self.button_config.visible = "1"
                self.button_create_config.visible = "0"
            else:
                self.button_config.visible = "0"
                self.button_create_config.visible = "1"

            response.shared_variables["plugin_id"] = plugin.id
            widget_plugins = WidgetPlugins()
            widget_plugins.set_single_data(plugin)
            widget_plugins.render(richtext=self.richtext_plugin)

            widget_macros = WidgetMacros()
            widget_macros.set_data(macros)
            widget_macros.render(self.datatable_macros)

            widget_timer = WidgetTimer()
            widget_timer.set_data(timer_list)
            widget_timer.render(self.datatable_timer)

            widget_custom_event = WidgetCustomEvent()
            widget_custom_event.set_data(custom_event_list)
            widget_custom_event.render(self.datatable_custom_event)

            widget_db = WidgetPluginDB()
            widget_db.set_data(DatabaseManager(plugin.guid).databaselist)
            widget_db.render(self.datatable_db)

            widget_resource = WidgetResource()
            widget_resource.set_data(
                ResourceFolderManager(plugin.guid).resourcelist, plugin.guid)
            widget_resource.render(self.datatable_resource)

            self.dialog_add_timer.action("hide", [])
        except Exception, ex:
            self.growl.title = lang["error"]
            self.growl.text = str(ex)
            self.growl.visible = "1"
Esempio n. 20
0
	from class_xml_plugin import XMLPlugin
	from class_xml_plugin_db import XMLPluginDB
	from class_xml_resource import XMLResource
	from class_xml_custom_event import XMLCustomEvent
	from utils.uuid import uuid4
	import base64
	from VEE_resources import create_plugin_dir, ResourceFolderManager
	from VEE_sqlite3 import DatabaseManager

	xml_data = request.arguments.get('xml_data', None)
	plugin_xml = base64.b64decode(xml_data)
	try:
		dom = parseString( plugin_xml)
		node = XMLPlugin( dom )

		plugin = Plugins()

		plugin.name = node.name
		plugin.description = node.description
		plugin.guid = node.guid
		plugin.version = node.version
		plugin.author = node.author

		exist_plugin = Plugins.get_by_guid(plugin.guid)
		if exist_plugin:
			if exist_plugin.version > plugin.version:
				raise Exception("You can't install old version plugin")
			else:
				if exist_plugin.picture:
					application.storage.delete( exist_plugin.picture )
				exist_plugin.delete()
Esempio n. 21
0
def main():

    from class_macro import Macros
    from class_timer import Timer
    from class_custom_event import CustomEvent
    from widget_plugins import WidgetPlugins
    from widget_macro import WidgetMacros
    from class_plugins import Plugins
    import localization

    lang = localization.get_lang()

    from VEE_events import event_map

    name = self.dialog_create_macro.form_macro.formtext_name.value = request.arguments.get(
        "formtext_name", "")
    macros_type = self.dialog_create_macro.form_macro.container_back.formlist_type.selectedvalue = request.arguments.get(
        "formlist_type", Macros.MacrosType.LIBRARY)
    event = self.dialog_create_macro.form_macro.container_back.formlist_event.selectedvalue = request.arguments.get(
        "formlist_event", "")
    location = self.dialog_create_macro.form_macro.container_back.formlist_location.selectedvalue = request.arguments.get(
        "formlist_location", "")
    description = self.dialog_create_macro.form_macro.formtextarea_description.value = request.arguments.get(
        "formtextarea_description", "")
    macros_id = self.dialog_create_macro.form_macro.formtext_id.value = request.arguments.get(
        "formtext_id", "")
    page = self.dialog_create_macro.form_macro.container_back.formlist_page.selectedvalue = request.arguments.get(
        "formlist_page", "")

    import re
    guid_regex = re.compile(
        "^[a-zA-Z0-9]{8}\-[a-zA-Z0-9]{4}\-[a-zA-Z0-9]{4}\-[a-zA-Z0-9]{4}\-[a-zA-Z0-9]{12}$"
    )

    class_name = ""
    timer_guid = ""
    custom_event_guid = ""
    is_button = "0"
    on_board = "0"

    if macros_type == Macros.MacrosType.EVENT:
        is_button = "0"
        if guid_regex.match(event):
            if Timer.get_timer_by_guid(event):
                timer_guid = event
                class_name = "VEE_TimerEvent"
            elif CustomEvent.get_custom_event_by_guid(event):
                custom_event_guid = event
                class_name = "VEE_CustomEvent"
        else:
            for e in event_map:
                if e == int(event):
                    class_name = event_map[e].__name__

    elif macros_type == Macros.MacrosType.BUTTON:
        is_button = "1"
        on_board = "1" if location and location == "1" else "0"

    elif macros_type != Macros.MacrosType.LIBRARY:
        macros_type = Macros.MacrosType.LIBRARY

    plugin_id = request.shared_variables["plugin_id"]
    plugin = Plugins.get_by_id(plugin_id)
    macros = Macros.get_by_id(macros_id) if macros_id else Macros()
    macros.name = name
    macros.class_name = class_name
    macros.timer_guid = timer_guid
    macros.custom_event_guid = custom_event_guid
    macros.is_button_macros = is_button
    macros.on_board = on_board
    macros.description = description
    macros.plugin_guid = plugin.guid
    macros.page = page
    macros.type = macros_type
    macros.save()

    plugin = Plugins.get_by_id(plugin_id)
    macros = plugin.get_macros()

    widget_macros = WidgetMacros()
    widget_macros.set_data(macros)
    widget_macros.render(self.datatable_macros)
    self.dialog_create_macro.action("hide", [])
Esempio n. 22
0
                    picture_name = ""
                    macros.macros_picture = ""
                    if child.macros_picture:
                        macros.macros_picture = picture_name = str(uuid4())
                        application.storage.write(
                            picture_name,
                            base64.b64decode(child.macros_picture))

                    macros.save()
                else:
                    self.growl.title = lang["error"]
                    self.growl.text = lang["xml_not_correctr_error"]
                    self.growl.visible = "1"

    if "op" in request.arguments and request.arguments.get("op") == "export":
        plugin = Plugins.get_by_id(session.get("plugin_id", ""))
        output = plugin.export()
        output_len = output.tell()
        output.seek(0)
        response.send_file(
            plugin.name.encode('utf8') + ".xml", output_len, output)

    if "formtext_pluginid" in request.arguments:
        args = request.arguments
        plugin = Plugins.get_by_id(args.get("formtext_pluginid", ""))
        file = request.arguments.get("uploader", "", castto=Attachment)

        if plugin and file:

            xml_data = file.handler.read()
            dom = parseString(xml_data)
Esempio n. 23
0
def main():

    import json, localization, base64
    from xml.dom.minidom import parseString
    from class_macro import Macros
    from class_plugins import Plugins
    from class_timer import Timer
    from class_custom_event import CustomEvent
    from class_xml_macro import XMLMacros
    from class_xml_timer import XMLTimer
    from class_xml_custom_event import XMLCustomEvent
    from class_xml_plugin import XMLPlugin
    from class_xml_plugin_db import XMLPluginDB
    from class_xml_resource import XMLResource
    from utils.uuid import uuid4
    from widget_localization import LocalizationWidget
    from widget_plugins import WidgetPlugins
    from VEE_resources import create_plugin_dir, ResourceFolderManager
    from VEE_sqlite3 import DatabaseManager

    lang = localization.get_lang()

    if "formbutton_save_plugin" in request.arguments:
        plugin = Plugins()
        plugin.guid = str(uuid4())
        plugin.name = request.arguments.get("formtext_name", "")
        plugin.author = request.arguments.get("formtext_author", "")
        plugin.description = request.arguments.get("formtextarea_description",
                                                   "")
        plugin.version = request.arguments.get("formtext_version", "")
        plugin.zindex = "1"

        if "uploader" in request.arguments:
            file = request.arguments.get("uploader", "", castto=Attachment)
            if file:
                plugin.picture = str(uuid4())
                application.storage.write(plugin.picture, file.handler.read())

        plugin.save()
        create_plugin_dir(plugin.guid)

    if "formbutton_upload_plugin" in request.arguments:
        if request.arguments.get("uploader", "", castto=Attachment):
            try:
                file = request.arguments.get("uploader", "", castto=Attachment)
                xml_data = file.handler.read()

                dom = parseString(xml_data)
                node = XMLPlugin(dom)

                if not Plugins.get_by_guid(node.guid):
                    plugin = Plugins()
                    plugin.name = node.name
                    plugin.description = node.description
                    plugin.guid = node.guid
                    plugin.version = node.version
                    plugin.author = node.author
                    plugin.protected = node.protected

                    plugin_picture_name = ""
                    plugin.picture = ""
                    if node.picture:
                        plugin.picture = plugin_picture_name = str(uuid4())
                        application.storage.write(
                            plugin_picture_name,
                            base64.b64decode(node.picture))
                    plugin.save()
                    create_plugin_dir(plugin.guid)

                    for child in node.childs:

                        if child.tag == "timer":
                            child = XMLTimer(child)

                            if child.name:
                                timer = Timer()
                                timer.fill_from_xml(child, node.guid)
                        elif child.tag == "custom_event":
                            child = XMLCustomEvent(child)

                            if child.name:
                                custom_event = CustomEvent()
                                custom_event.fill_from_xml(child, node.guid)
                        elif child.tag == "macro":
                            child = XMLMacros(child)
                            if child.name and child.source:
                                macros = Macros()
                                macros.fill_from_xml(child, node.guid)
                        elif child.tag == "database":
                            child = XMLPluginDB(child)
                            if child.name:
                                DatabaseManager(plugin.guid).import_db(
                                    child.name,
                                    base64.b64decode(child.db_source))
                        elif child.tag == "resource":
                            child = XMLResource(child)

                            if child.name:
                                ResourceFolderManager(plugin.guid).import_res(
                                    child.name,
                                    base64.b64decode(child.res_source))
                        else:
                            raise Exception(
                                lang.get("xml_not_correctr_error",
                                         "xml_not_correctr_error"))
                else:
                    raise Exception(lang.get("plugin_exist", "plugin_exist"))

            except Exception, ex:
                self.growl.title = lang["error"]
                self.growl.text = ex
                self.growl.show = "1"