def unregister_macro(macro):
    import VEE_events

    if macro.type == macro.MacrosType.LIBRARY:
        Macros.update_all_macro_with_library(macro)
        return

    event_class =   VEE_events.VEE_ButtonEvent if macro.type == macro.MacrosType.BUTTON else \
                    getattr( VEE_events, macro.class_name, None )

    if not event_class: return

    if event_class == VEE_events.VEE_TimerEvent:
        from class_timer import Timer
        Timer.register_timer_by_guid(macro.timer_guid)
        data = (macro.timer_guid, )

    elif event_class == VEE_events.VEE_CustomEvent:
        from class_custom_event import CustomEvent
        custom_event = CustomEvent.get_custom_event_by_guid(
            macro.custom_event_guid)
        data = (custom_event.plugin_guid, custom_event.name)

    elif event_class == VEE_events.VEE_ButtonEvent:
        data = (macro.namespace, macro.guid)

    else:
        data = (None, )

    key = event_class.get_key(*data)

    from VEE_core import engine
    engine.unregister_dispatcher(event_class, key, macro.guid)
示例#2
0
    def export(self):
        from StringIO import StringIO
        import base64

        from class_xml_plugin import XMLPlugin
        xml_plugin = XMLPlugin()

        xml_plugin.picture = base64.b64encode(
            application.storage.readall(self.picture)) if self.picture else ''
        xml_plugin.description = self.description if self.description else ''
        xml_plugin.name = self.name if self.name else ''
        xml_plugin.version = self.version if self.version else ''
        xml_plugin.author = self.author if self.author else ''
        xml_plugin.guid = self.guid

        #raise Exception(name, description, author)
        #outp.write(xml_plugin"<plugin guid='" + self.guid + "' name='" + name + "' description='" + description + "' picture='" + picture + "' author='" + author + "' version='"+ version +"'>")

        timers = self.get_timer()
        for timer in timers:
            from class_timer import Timer
            t = Timer.get_by_id(timer.id)
            xml_plugin.append_child(t.get_xmlnode())

        custom_events = self.get_custom_event()
        for cevent in custom_events:
            from class_custom_event import CustomEvent
            ce = CustomEvent.get_by_id(cevent.id)
            xml_plugin.append_child(ce.get_xmlnode())

        from VEE_sqlite3 import DatabaseManager
        from VEE_resources import ResourceFolderManager

        db_list = DatabaseManager(self.guid).databaselist
        for db in db_list:
            from class_plugin_db import PluginDB
            plugin_db = PluginDB(db, DatabaseManager(self.guid).export_db(db))
            xml_plugin.append_child(plugin_db.get_xmlnode())

        res_list = ResourceFolderManager(self.guid).resourcelist
        for res in res_list:
            from class_resource import Resource
            resource = Resource(
                res,
                ResourceFolderManager(self.guid).export_res(res))
            xml_plugin.append_child(resource.get_xmlnode())

        macros = self.get_macros()
        for macro in macros:
            from class_macro import Macros
            m = Macros.get_by_id(macro.id)
            xml_plugin.append_child(m.get_xmlnode())

        outp = StringIO()
        outp.write(xml_plugin.toprettyxml().encode('utf8'))
        return outp
示例#3
0
def main():

    from class_timer import Timer
    timer_id = request.shared_variables["timer_id"]
    if timer_id:
        self.dialog_add_timer.form_add_timer.formtext_id.value = timer_id
        timer = Timer.get_by_id(timer_id)
        self.dialog_add_timer.form_add_timer.formtext_name.value = timer.name
        self.dialog_add_timer.form_add_timer.formtext_period.value = timer.period
    else:
        self.dialog_add_timer.form_add_timer.formtext_id.value = ""
        self.dialog_add_timer.form_add_timer.formtext_name.value = ""
        self.dialog_add_timer.form_add_timer.formtext_period.value = "00:00:00:00"
示例#4
0
    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)
示例#5
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"]
示例#6
0
def create_game_display(
        screen, nbr_cases_y,
        nbr_bomb):  # Création des afficheur présents pendant la partie
    font = pg.font.Font(os.path.join('ressources', 'crystal_font.ttf'), 20)

    # Création de l'afficheur du nombre de bombes dans la grille
    afficheur_bombes = Message(screen, f"{nbr_bomb} BOMBES",
                               [nbr_cases_y * 22, 0], font, (255, 0, 0),
                               (0, 0, 0))

    # Création de l'afficheur du nombre de drapeaux sur la grille
    afficheur_flags = Message(
        screen, "0 DRAPEAUX",
        [afficheur_bombes.get_msg_y(),
         afficheur_bombes.get_msg_width() + 20], font, (255, 0, 0), (0, 0, 0))

    # Création du timer
    timer = Timer(screen, [
        afficheur_flags.get_msg_y(),
        afficheur_flags.get_msg_x() + afficheur_flags.get_msg_width() + 20
    ], font, (255, 0, 0), (0, 0, 0))

    return afficheur_bombes, afficheur_flags, timer
示例#7
0
		if node.picture:
			plugin.picture = str(uuid4())
			application.storage.write( plugin.picture, base64.b64decode(node.picture))

		plugin.save()

		create_plugin_dir( plugin.guid )
		dbManager = DatabaseManager( plugin.guid )
		resManager = ResourceFolderManager( 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":
示例#8
0
 def get_timer(self):
     from class_timer import Timer
     self.__timer = Timer.get_timer_by_plugin_guid(self.guid)
     return self.__timer
示例#9
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"
示例#10
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", [])