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
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." ])
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")
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() plugin.picture = "" if node.picture: plugin.picture = str(uuid4()) application.storage.write( plugin.picture, base64.b64decode(node.picture)) plugin.save()
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"