def __update(self):
        Database.macrosdb().commit(
            """UPDATE macros
                SET
                    name=?,
                    code=?,
                    class_name=?,
                    is_button_macros=?,
                    on_board=?,
                    picture=?,
                    guid=?,
                    page=?,
                    description=?,
                    zindex=?,
                    timer_guid=?,
                    plugin_guid=?,
                    namespace=?,
                    page=?,
                    custom_event_guid=?,
                    type=?
                    WHERE id=?""",
            (self.name, self.code, self.class_name, self.is_button_macros,
             self.on_board, self.macros_picture, self.guid, self.page,
             self.description, self.zindex, self.timer_guid, self.plugin_guid,
             self.namespace, self.page, self.custom_event_guid, self.type,
             self.id))

        return self
    def __update(self):
        Database.macrosdb().commit(
            """UPDATE custom_event
				SET
					name=?,
					guid=?,
					plugin_guid=?
					WHERE id=?""", (self.name, self.guid, self.plugin_guid, self.id))
        self.update_custom_event()
        return self
Example #3
0
    def __update(self):
        Database.macrosdb().commit(
            """UPDATE timer
				SET
					name=?,
					period=?,
					guid=?,
					plugin_guid=?
					WHERE id=?""",
            (self.name, self.period, self.guid, self.plugin_guid, self.id))
        self.update_timer()
        return self
    def delete(self):
        from class_macro import Macros

        macros_list = Macros.get_macros_by_custom_event_guid(self.guid)
        for macros in macros_list:
            macros.class_name = "NULL"
            macros.custom_event = "NULL"
            macros.is_button_macros = "1"
            macros.on_board = "0"
            macros.save()

        self.unregister()
        Database.macrosdb().commit("""DELETE FROM custom_event WHERE id=?""",
                                   (self.id, ))
    def get_all_button(self):
        db_rows = Database.macrosdb().fetch_all(
            _SQL_SELECT_HEADER +
            "WHERE is_button_macros='1' AND on_board='0'", )

        return [self().__fill_from_row(row)
                for row in db_rows] if db_rows else []
    def get_macros_by_custom_event_guid(self, custom_event_guid):
        db_rows = Database.macrosdb().fetch_all(
            _SQL_SELECT_HEADER + "WHERE custom_event_guid=?",
            (custom_event_guid, ))

        return [self().__fill_from_row(row)
                for row in db_rows] if db_rows else []
Example #7
0
    def delete(self, keep_storage=False):
        macros_list = self.get_macros()
        for macro in macros_list:
            macro.delete()
        timer_list = self.get_timer()
        for timer in timer_list:
            timer.delete()
        custom_event_list = self.get_custom_event()
        for cevent in custom_event_list:
            cevent.delete()

        Database.macrosdb().commit("""DELETE FROM plugin WHERE id=?""",
                                   (self.id, ))
        if not keep_storage:
            Database.macrosdb().commit(
                """DELETE FROM kv_macro_storage WHERE namespace=?""",
                (self.guid, ))
Example #8
0
    def __update(self):
        Database.macrosdb().commit(
            """UPDATE plugin
			SET
				name=?,
				description=?,
				author=?,
				picture=?,
				guid=?,
				zindex=?,
				version=?,
				protected=?
			WHERE id=?""",
            (self.name, self.description, self.author, self.picture, self.guid,
             self.zindex, self.version, self.protected, self.id))

        return self
Example #9
0
    def __insert(self):
        self.guid = str(uuid4()) if self.guid is None else self.guid
        self.id = Database.macrosdb().commit(
            """INSERT INTO timer (name, period, guid, plugin_guid) VALUES (?,?,?,?)""",
            (self.name, self.period, self.guid, self.plugin_guid))

        self.register()
        return self
Example #10
0
def clear_all():

    # clear database
    Database.maindb().clean()
    Database.maindb().commit('VACUUM')

    Database.macrosdb().clean()
    Database.macrosdb().commit('VACUUM')

    # clear ProAdmin scheme
    ProAdmin.scheme().delete()

    # clear application storage
    application.storage.rmtree('.')

    # clear all listeners and timers in VEE_core
    engine.clear_all()
    def __insert(self):
        self.guid = str(uuid4()) if self.guid is None else self.guid
        #raise Exception(self.guid, self.name)
        self.id = Database.macrosdb().commit(
            """INSERT INTO custom_event (name, guid, plugin_guid) VALUES (?,?,?)""",
            (self.name, self.guid, self.plugin_guid))

        self.register()
        return self
    def update_all_macro_with_library(cls, library):

        db_rows = Database.macrosdb().fetch_all(
            _SQL_SELECT_HEADER +
            """WHERE plugin_guid=? and code LIKE "%'#include("||?||")%" """,
            (library.plugin_guid, library.name))

        return map(register_macro,
                   [cls().__fill_from_row(row)
                    for row in db_rows] if db_rows else [])
    def get_custom_event_by_plugin_guid(self, plugin_guid):
        db_rows = Database.macrosdb().fetch_all(
            """
			SELECT
				custom_event.id,
				custom_event.name,
				custom_event.guid,
				custom_event.plugin_guid
			FROM `custom_event`
			WHERE custom_event.plugin_guid=?""", (plugin_guid, ))
        return [self().__fill_from_row(row) for row in db_rows]
Example #14
0
    def get_timer_by_plugin_guid(self, plugin_guid):
        db_rows = Database.macrosdb().fetch_all(
            """
			SELECT
				timer.id,
				timer.name,
				timer.period,
				timer.guid,
				timer.plugin_guid
			FROM `timer`
			WHERE timer.plugin_guid=?""", (plugin_guid, ))
        return [self().__fill_from_row(row) for row in db_rows]
    def get_custom_event_by_guid(self, guid):
        db_row = Database.macrosdb().fetch_one(
            """
			SELECT
				custom_event.id,
				custom_event.name,
				custom_event.guid,
				custom_event.plugin_guid
			FROM `custom_event`
			WHERE custom_event.guid=?""", (guid, ))

        return self().__fill_from_row(db_row) if db_row else None
Example #16
0
    def get_timer_by_guid(self, guid):
        db_row = Database.macrosdb().fetch_one(
            """
			SELECT
				timer.id,
				timer.name,
				timer.period,
				timer.guid,
				timer.plugin_guid
			FROM `timer`
			WHERE timer.guid=?""", (guid, ))

        return self().__fill_from_row(db_row) if db_row else None
    def __insert(self):
        self.guid = str(uuid4()) if self.guid is None else self.guid
        self.id = Database.macrosdb().commit(
            "INSERT INTO macros (name, code, class_name, is_button_macros,"
            "on_board, picture, guid, page, description, zindex, timer_guid,"
            "plugin_guid, namespace, page, custom_event_guid,type) VALUES"
            "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
            "",
            (self.name, self.code, self.class_name, self.is_button_macros,
             self.on_board, self.macros_picture, self.guid, self.page,
             self.description, self.zindex, self.timer_guid, self.plugin_guid,
             self.plugin_guid, self.page, self.custom_event_guid, self.type))

        return self
Example #18
0
    def get_all(self):
        db_rows = Database.macrosdb().fetch_all(
            """
			SELECT
				plugin.id,
				plugin.name,
				plugin.description,
				plugin.author,
				plugin.picture,
				plugin.guid,
				plugin.zindex,
				plugin.version,
				plugin.protected
			FROM `plugin`""", )

        return [self().__fill_from_row(row) for row in db_rows]
Example #19
0
    def get_by_guid(self, guid):
        db_row = Database.macrosdb().fetch_one(
            """
			SELECT
				plugin.id,
				plugin.name,
				plugin.description,
				plugin.author,
				plugin.picture,
				plugin.guid,
				plugin.zindex,
				plugin.version,
				plugin.protected
			FROM `plugin`
			WHERE guid=?""", (guid, ))

        return self().__fill_from_row(db_row) if db_row else None
    def libraries(self):
        lib_names = LIB_NAME_REGEXP.findall(self.code)
        if not lib_names: return []

        lib_names = OrderedDict.fromkeys([n.lower() for n in lib_names])

        db_rows = Database.macrosdb().fetch_all(
            _SQL_SELECT_HEADER + "WHERE plugin_guid=? and type=?",
            (self.plugin_guid, self.MacrosType.LIBRARY))

        libraries = [Macros().__fill_from_row(row)
                     for row in db_rows] if db_rows else []

        for lib in libraries:
            if lib.name.lower() in lib_names:
                lib_names[lib.name.lower()] = lib

        return [lib for lib in lib_names.values() if lib is not None]
    def get_config_macro(self, plugin_guid):
        db_row = Database.macrosdb().fetch_one(
            _SQL_SELECT_HEADER + "WHERE plugin_guid=? AND name='config'",
            (plugin_guid, ))

        return self().__fill_from_row(db_row) if db_row else None
 def v_items( self ):
     return  [ (row[0], row[1] ) for row in Database.macrosdb().fetch_all(
             "SELECT key, value FROM `{0}` WHERE namespace=?".format( v_dbdictionary.__DB_NAME ),
             (  self.__namespace, ) ) ]
 def v_keys( self ):
     return  [ row[0] for row in Database.macrosdb().fetch_all(
             "SELECT key FROM `{0}` WHERE namespace=?".format( v_dbdictionary.__DB_NAME ),
             (  self.__namespace, ) ) ]
 def __contains__( self, key ):
     return bool( Database.macrosdb().fetch_one(
             "SELECT value FROM `{0}` WHERE key=? AND namespace=?".format( v_dbdictionary.__DB_NAME ),
             (  key , self.__namespace ) ) )
 def erase( self, key ):
     Database.macrosdb().commit(
             "DELETE FROM `{0}` WHERE key=? AND namespace=?".format( v_dbdictionary.__DB_NAME ),
             (  key, self.__namespace ) )
 def let( self, key = None, *arguments, **keywords ):
     if not key: raise errors.wrong_number_of_arguments
     Database.macrosdb().commit(
             "REPLACE INTO `{0}` (key, value, namespace) VALUES (?, ?, ?)".format( v_dbdictionary.__DB_NAME ),
             (  key , keywords[ "let" ], self.__namespace ) )
 def get( self, key ):
     row = Database.macrosdb().fetch_one(
             "SELECT value FROM `{0}` WHERE key=? AND namespace=?".format( v_dbdictionary.__DB_NAME ),
             (  key , self.__namespace ) )
     return row[0] if row else None
    def get_all_event_macros(self):
        db_rows = Database.macrosdb().fetch_all(
            _SQL_SELECT_HEADER + "WHERE class_name<>''", )

        return [self().__fill_from_row(row)
                for row in db_rows] if db_rows else []
    def get_all_non_library(self):
        db_rows = Database.macrosdb().fetch_all(
            _SQL_SELECT_HEADER + "WHERE type<>?", (self.MacrosType.LIBRARY, ))

        return [self().__fill_from_row(row)
                for row in db_rows] if db_rows else []
    def get_by_guid(self, guid):
        db_row = Database.macrosdb().fetch_one(
            _SQL_SELECT_HEADER + "WHERE guid=?", (guid, ))

        return self().__fill_from_row(db_row) if db_row else None