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"
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"] = ""
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 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 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"]
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 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", [])
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"] = ""
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"] = ""
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"]
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()
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 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"
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", [])
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)