Esempio n. 1
0
    def uninstall_package(self):
        import shutil
        packages = [i['pack_name'] for i in self.known_packages]
        if len(packages) == 0:
            tools.showDialog.ok(tools.addonName,
                                tools.lang(32074).encode('utf-8'))
            return
        selection = tools.showDialog.select(
            "%s: %s Providers" %
            (tools.addonName, tools.lang(32075).encode('utf-8')), packages)
        if selection == -1:
            return
        package_name = packages[selection]
        confirm = tools.showDialog.yesno(
            tools.addonName,
            tools.lang(32076).encode('utf-8') + " %s" % package_name)
        if confirm == 0:
            return

        provider_path = os.path.join(self.providers_path, package_name)
        modules_path = os.path.join(self.modules_path, package_name)
        meta_path = os.path.join(self.meta_path, '%s.json' % package_name)
        if os.path.exists(provider_path):
            shutil.rmtree(provider_path)
        if os.path.exists(modules_path):
            shutil.rmtree(modules_path)
        if os.path.exists(meta_path):
            os.remove(meta_path)

        database.remove_package_providers(package_name)
        database.remove_provider_package(package_name)
        tools.showDialog.ok(
            tools.addonName,
            '%s ' % package_name + tools.lang(32077).encode('utf-8'))
Esempio n. 2
0
    def uninstall_package(self, package=None, silent=False):
        import shutil
        packages = [i['pack_name'] for i in self.known_packages]
        if package is None:
            if len(packages) == 0:
                tools.showDialog.ok(tools.addonName, tools.lang(32074))
                return
            selection = tools.showDialog.select(
                "%s: %s %s" %
                (tools.addonName, tools.lang(32075), tools.lang(40068)),
                packages)
            if selection == -1:
                return
            package_name = packages[selection]
            confirm = tools.showDialog.yesno(
                tools.addonName,
                tools.lang(32076) + " %s" % package_name)
            if confirm == 0:
                return
        else:
            package_name = package

        try:
            provider_path = os.path.join(self.providers_path, package_name)
            modules_path = os.path.join(self.modules_path, package_name)
            meta_path = os.path.join(self.meta_path, '%s.json' % package_name)
            if os.path.exists(provider_path):
                shutil.rmtree(provider_path)
            if os.path.exists(modules_path):
                shutil.rmtree(modules_path)
            if os.path.exists(meta_path):
                os.remove(meta_path)

            database.remove_package_providers(package_name)
            database.remove_provider_package(package_name)
            import time
            time.sleep(2)
            if not silent:
                tools.showDialog.ok(tools.addonName,
                                    '%s ' % package_name + tools.lang(32077))
        except:
            tools.showDialog.ok(
                tools.addonName,
                tools.language(40118).enocde('utf-8') %
                (tools.addonName, package_name))