Exemple #1
0
    def install_in_app_dir(self, paths):

        lib_dir = self.lib_path
        app_dir = self.app_path
        plugin_dir = self.plugin_path

        # delete lib dir
        self.delete_path(lib_dir)

        # delete app, plugin dir if egg for them exists
        for d, p in ((plugin_dir, PLUGIN_PREFIX),
                     (app_dir, APPLICATION_PREFIX)):
            if [name for name, src, pkgname in paths if pkgname.startswith(p)]:
                self.delete_path(d)

        for d in [lib_dir, plugin_dir]:
            if not os.path.exists(d):
                os.mkdir(d)

        # Copy all files.
        for name, src, pkgname in paths:
            if name in self.ignore_packages:
                # This package or module must be ignored.
                continue

            if pkgname.startswith('aha.application'):
                if src.endswith('application'):
                    dst = os.path.join(app_dir)
                else:
                    dst = os.path.split(app_dir)[0]
                    dst = os.path.join(dst, os.path.split(src)[1])
            elif pkgname.startswith('aha.plugin'):
                dst = os.path.join(plugin_dir, name)
            else:
                dst = os.path.join(lib_dir, name)

            if not os.path.isdir(src):
                # Try single files listed as modules.
                src += '.py'
                dst += '.py'
                if not os.path.isfile(src) or os.path.isfile(dst):
                    continue

            self.logger.info('Copying %r to %r...' % (src, dst))

            copytree(src, dst, os.path.dirname(src) + os.sep,
                ignore=ignore_patterns(*self.ignore_globs),
                logger=self.logger)

        # Save README.
        f = open(os.path.join(lib_dir, 'README.txt'), 'w')
        f.write(app_lib.LIB_README)
        f.close()

        # make __init__.py explicitry.
        for d in [lib_dir, plugin_dir]:
            open(os.path.join(d, '__init__.py'), 'w')
Exemple #2
0
    def install_in_app_dir(self, paths):
        # Delete old libs.
        self.delete_libs()

        if self.use_zip:
            # Create temporary directory for the zip files.
            tmp_dir = os.path.join(tempfile.gettempdir(), uuid.uuid4().hex)
        else:
            tmp_dir = self.lib_path

        if not os.path.exists(tmp_dir):
            os.mkdir(tmp_dir)

        # Copy all files.
        for name, src in paths:
            if name in self.ignore_packages:
                # This package or module must be ignored.
                continue

            dst = os.path.join(tmp_dir, name)
            if not os.path.isdir(src):
                # Try single files listed as modules.
                src += '.py'
                dst += '.py'
                if not os.path.isfile(src) or os.path.isfile(dst):
                    continue

            self.logger.info('Copying %r...' % src)

            to_ignore = recipe.ignore_patterns(*self.ignore_globs)
            recipe.copytree(
                src,
                dst,
                os.path.dirname(src) + os.sep,
                ignore=to_ignore,
                logger=self.logger
            )

        # Save README.
        f = open(os.path.join(tmp_dir, 'README.txt'), 'w')
        f.write(LIB_README)
        f.close()

        if self.use_zip:
            # Zip file and remove temporary dir.
            recipe.zipdir(tmp_dir, self.lib_path)
            if os.path.isdir(tmp_dir):
                shutil.rmtree(tmp_dir)
Exemple #3
0
    def install_in_app_dir(self, paths):
        # Delete old libs.
        self.delete_libs()

        if self.use_zip:
            # Create temporary directory for the zip files.
            tmp_dir = os.path.join(tempfile.gettempdir(), uuid.uuid4().hex)
        else:
            tmp_dir = self.lib_path

        if not os.path.exists(tmp_dir):
            os.mkdir(tmp_dir)

        # Copy all files.
        for name, src in paths:
            if name in self.ignore_packages:
                # This package or module must be ignored.
                continue

            dst = os.path.join(tmp_dir, name)
            if not os.path.isdir(src):
                # Try single files listed as modules.
                src += '.py'
                dst += '.py'
                if not os.path.isfile(src) or os.path.isfile(dst):
                    continue

            self.logger.info('Copying %r...' % src)

            to_ignore = recipe.ignore_patterns(*self.ignore_globs)
            recipe.copytree(src,
                            dst,
                            os.path.dirname(src) + os.sep,
                            ignore=to_ignore,
                            logger=self.logger)

        # Save README.
        f = open(os.path.join(tmp_dir, 'README.txt'), 'w')
        f.write(LIB_README)
        f.close()

        if self.use_zip:
            # Zip file and remove temporary dir.
            recipe.zipdir(tmp_dir, self.lib_path)
            if os.path.isdir(tmp_dir):
                shutil.rmtree(tmp_dir)