コード例 #1
0
ファイル: module.py プロジェクト: skarphed/skarphed
    def uninstall_module(cls,module, hard=False):
        """
        uninstall a module
        the flag "hard" actually deletes the files of this module in modpath
        module can be module or module meta
        """
        if module.__class__.__name__ != "Module":
            nr = cls._get_module_id_from_name(module_meta["name"])
            module = cls.get_module(nr)

        Action.delete_actions_with_module(module)
        View.delete_mappings_with_module(module)
        CSSManager().delete_definitions_with_module(module)

        db = Database()
        db.remove_tables_for_module(module)
        Permission.remove_permissions_for_module(module)

        if hard:
            modpath = Configuration().get_entry('global.modpath')
            version = module.get_version()
            shutil.rmtree(modpath+"/"+module.get_name()+"/v"+version[0]+"_"+version[1]+"_"+version[2])

        cls._unregister_module(module)
        PokeManager.add_activity(ActivityType.MODULE)
コード例 #2
0
ファイル: module.py プロジェクト: skarphed/skarphed
    def update_module(cls,module):
        """
        updates the given module
        """
        # - neueste versionsnummer holen
        # - pruefen ob bereits auf fs vorhanden
        #   - wenn nein, holen
        # - neues modul laden
        # - tabellen aendern
        # - permissions aendern
        # - datenbank-versionseintraege updaten
        if module.__class__.__name__ != "Module":
            nr = cls._get_module_id_from_name(module_meta["name"])
            module = cls.get_module(nr)

        modpath = Configuration().get_entry('global.modpath')

        repo = cls.get_repository()
        latest_version = repo.get_latest_version(module)

        latest_path = modpath+"/"+latest_version["name"]+"/v"+\
                              str(latest_version["version_major"])+"_"+ \
                              str(latest_version["version_minor"])+"_"+ \
                              str(latest_version["revision"])

        if cls.compare_versions(latest_version, module) == 1:
            if not os.path.exists(latest_path):
                datapath = repo.download_module(latest_version)
                os.mkdir(latest_path)
                tar = tarfile.open(datapath, "r:gz")
                tar.extractall(latest_path)
            nr = cls._get_module_id_from_name(latest_version["name"])

            db = Database()
            stmnt = "UPDATE MODULES SET MOD_VERSIONMAJOR = ?, \
                                        MOD_VERSIONMINOR = ?, \
                                        MOD_VERSIONREV = ? \
                        WHERE MOD_ID = ? ;"
            db.query(stmnt,(latest_version["version_major"],
                                       latest_version["version_minor"],
                                       latest_version["revision"], 
                                       nr),commit=True)
            updated_module = cls.get_module(nr)
            db.update_tables_for_module(updated_module)
            Permission.update_permissions_for_module(updated_module)

        PokeManager.add_activity(ActivityType.MODULE)
コード例 #3
0
ファイル: module.py プロジェクト: skarphed/skarphed
        # CREATE PERMISSIONS FOR MOUDLE
        try:
            Permission.create_permissions_for_module(module)
        except PermissionException, e: #revert on error
            cls._unregister_module(module)
            shutil.rmtree(modulepath)
            os.remove(datapath)
            raise e

        # CREATE DATBASE TABLES FOR MODULE
        try:
            db.create_tables_for_module(module)
        except DatabaseException, e:
            cls._unregister_module(module)
            shutil.rmtree(modulepath)
            Permission.remove_permissions_for_module(module)
            os.remove(datapath)
            raise e
        
        os.remove(datapath)
        PokeManager.add_activity(ActivityType.MODULE)

    @classmethod
    def update_module(cls,module):
        """
        updates the given module
        """
        # - neueste versionsnummer holen
        # - pruefen ob bereits auf fs vorhanden
        #   - wenn nein, holen
        # - neues modul laden