예제 #1
0
 def on_error(func, path, error):
     if func == os.path.islink:
         # if symlink
         os.unlink(path)
         return
     # access is denied or other
     raise PluginsystemError(error[1][1])
 def install_from_zip(self, zip_filename, owerwrite=None):
     '''
     Install plagin from zip and return plugin
     '''
     try:
         zip_file = zipfile.ZipFile(zip_filename)
     except zipfile.BadZipfile, e:
         # it is not zip file
         raise PluginsystemError(_('Archive corrupted'))
예제 #3
0
    def install_from_zip(self, zip_filename, owerwrite=None):
        '''
        Install plagin from zip and return plugin
        '''
        try:
            zip_file = zipfile.ZipFile(zip_filename)
        except zipfile.BadZipfile:
            # it is not zip file
            raise PluginsystemError(_('Archive corrupted'))
        except IOError:
            raise PluginsystemError(_('Archive empty'))

        if zip_file.testzip():
            # CRC error
            raise PluginsystemError(_('Archive corrupted'))

        dirs = []
        manifest = None
        for filename in zip_file.namelist():
            if filename.startswith('.') or filename.startswith('/') or \
            ('/' not in filename):
                # members not safe
                raise PluginsystemError(_('Archive is malformed'))
            if filename.endswith('/') and filename.find('/', 0, -1) < 0:
                dirs.append(filename)
            if 'manifest.ini' in filename.split('/')[1]:
                manifest = True
        if not manifest:
            return
        if len(dirs) > 1:
            raise PluginsystemError(_('Archive is malformed'))

        base_dir, user_dir = gajim.PLUGINS_DIRS
        plugin_dir = os.path.join(user_dir, dirs[0])

        if os.path.isdir(plugin_dir):
            # Plugin dir already exists
            if not owerwrite:
                raise PluginsystemError(_('Plugin already exists'))
            self.remove_plugin(self.get_plugin_by_path(plugin_dir))

        zip_file.extractall(user_dir)
        zip_file.close()
        path = os.path.join(user_dir, dirs[0])
        plugins = self.scan_dir_for_plugins(plugin_dir, False)
        if not plugins:
            return
        self.add_plugin(plugins[0])
        plugin = self.plugins[-1]
        return plugin
                              (module_attr_name,
                               'wrong manifest file. section are required!'))

        return plugins_found

    def install_from_zip(self, zip_filename, owerwrite=None):
        '''
        Install plagin from zip and return plugin
        '''
        try:
            zip_file = zipfile.ZipFile(zip_filename)
        except zipfile.BadZipfile, e:
            # it is not zip file
            raise PluginsystemError(_('Archive corrupted'))
        except IOError, e:
            raise PluginsystemError(_('Archive empty'))

        if zip_file.testzip():
            # CRC error
            raise PluginsystemError(_('Archive corrupted'))

        dirs = []
        manifest = None
        for filename in zip_file.namelist():
            print filename
            if filename.startswith('.') or filename.startswith('/') or \
            ('/' not in filename):
                # members not safe
                raise PluginsystemError(_('Archive is malformed'))
            if filename.endswith('/') and filename.find('/', 0, -1) < 0:
                dirs.append(filename)