Example #1
0
    def make_wrapper(self):
        path = self.buildout["buildout"]["bin-directory"]
        egg_paths = [
            self.buildout["buildout"]["develop-eggs-directory"],
            self.buildout["buildout"]["eggs-directory"],
            ]
        arguments = "'%s'" % self.ininame

        ws = easy_install.working_set(["isotoma.recipe.pound"], sys.executable, egg_paths)
        easy_install.scripts([(self.name, "isotoma.recipe.pound.cyclescript", "execute")], ws, sys.executable, path, arguments=arguments)
        self.options.created(os.path.join(path, self.name))
Example #2
0
    def install(self):
        path = self.buildout["buildout"]["bin-directory"]
        egg_paths = [
            self.buildout["buildout"]["develop-eggs-directory"],
            self.buildout["buildout"]["eggs-directory"],
            ]

        ws = easy_install.working_set(["isotoma.recipe.apache"], sys.executable, egg_paths)
        easy_install.scripts([(self.name, "isotoma.recipe.apache.logfilter", "main")], ws, sys.executable, path)

        self.installed.append(os.path.join(path, self.name))

        return self.installed
Example #3
0
    def create_script(self, name, path, settings, template, arguments):
        """Create arbitrary script.

        This script will also include the eventual code found in
        ``initialization`` and will also set (via ``os.environ``) the
        environment variables found in ``environment-vars``
        """

        self.logger.info("Creating script at %s" %
                         (os.path.join(path, name), ))
        settings = settings.rsplit(".", 1)
        module = settings[0]
        attrs = ""
        if len(settings) > 1:
            attrs = "." + settings[1]

        old_script_template = easy_install.script_template
        easy_install.script_template = template
        script = easy_install.scripts(reqs=[(name, module, attrs)],
                                      working_set=self.working_set[1],
                                      executable=self.options['executable'],
                                      dest=path,
                                      extra_paths=self.extra_paths,
                                      initialization=self.get_initialization(),
                                      arguments=str(arguments))
        easy_install.script_template = old_script_template
        return script
    def create_script(self, name, path, settings, template, arguments):
        """Create arbitrary script.

        This script will also include the eventual code found in
        ``initialization`` and will also set (via ``os.environ``) the
        environment variables found in ``environment-vars``
        """

        self.logger.info(
            "Creating script at %s" % (os.path.join(path, name),)
        )
        settings = settings.rsplit(".", 1)
        module = settings[0]
        attrs = ""
        if len(settings) > 1:
            attrs = "." + settings[1]

        old_script_template = easy_install.script_template
        easy_install.script_template = template
        script = easy_install.scripts(
            reqs=[(name, module, attrs)],
            working_set=self.working_set[1],
            executable=self.options['executable'],
            dest=path,
            extra_paths=self.extra_paths,
            initialization=self.get_initialization(),
            arguments=str(arguments)
        )
        easy_install.script_template = old_script_template
        return script
Example #5
0
    def wrapper(self, postfix, module, call):
        scriptname = self.name + postfix
        bin_directory = self.buildout['buildout']['bin-directory']

        egg_paths = [
            self.buildout["buildout"]["develop-eggs-directory"],
            self.buildout["buildout"]["eggs-directory"],
            ]

        module = "badgerproxy.scripts." + module

        working_set = easy_install.working_set(["badgerproxy"], sys.executable, egg_paths)

        arguments = "'%s'" % self.options['systemconf']

        easy_install.scripts(
            [(scriptname, module, call)],
            working_set,
            sys.executable,
            bin_directory,
            arguments=arguments)

        self.options.created(os.path.join(bin_directory, scriptname))
Example #6
0
    def install(self):
        if self.options['settings'] and self.options['inst_apps']:
            raise ImproperlyConfigured(
                'Cannot define a settings module and a list of installed apps')

        __, working_set = self.egg.working_set(self._packages())
        return easy_install.scripts(
            [(self.name, self.script_path, 'main')],
            working_set,
            sys.executable,
            self.options['bin_dir'],
            extra_paths=self.options['extra-paths'].split(';'),
            arguments=self._arguments(),
            initialization=self._initialization())
    def install(self):

        # Create var dirs
        var = os.path.join(self.buildout['buildout']['directory'], 'var')
        fs = os.path.join(self.buildout['buildout']['directory'], 'var', 'filestorage')
        bs = os.path.join(self.buildout['buildout']['directory'], 'var', 'blobstorage')
        mkdir(var)
        mkdir(fs)
        mkdir(bs)

        # Generate paster script
        requirements, ws = self.egg.working_set(['collective.recipe.bluebream'])
        return scripts(['PasteScript'], ws,
            self.buildout['buildout']['executable'],
            self.buildout['buildout']['bin-directory'])
Example #8
0
    def install(self):
        if self.__skip:
            self.__logger.info('skipped')
            return []

        from zc.buildout import easy_install
        import pkg_resources
        import sys
        ws = [pkg_resources.get_distribution(dist)
              for dist in ['unokit', 'oxt.tool']]
        entrypoints = [(self.__name, 'oxt_tool', 'install')]
        arguments = '%r' % self.__unopkg
        return easy_install.scripts(entrypoints,
                                    ws, sys.executable, self.__bindir,
                                    arguments=arguments)
Example #9
0
    def install(self):
        pybin = self.buildout["buildout"]["executable"]
        bindir = self.buildout['buildout']['bin-directory']
        partsdir = os.path.join(self.buildout['buildout']['parts-directory'], self.name)
        cfg = os.path.join(partsdir, "cluster.cfg")

        if not os.path.exists(partsdir):
            os.makedirs(partsdir)

        services = []
        for s in self.options["services"].strip().split():
            s = s.strip()
            if s:
                services.append(s)

        config = ConfigParser.RawConfigParser()

        config.add_section('cluster')
        config.set('cluster', 'services', ' '.join(services))
        config.set('cluster', 'name', self.name)
        config.set('cluster', 'bindir', bindir)
        config.set('cluster', 'varrundir', self.options["varrun-directory"])
        config.set('cluster', 'user', self.options.get("force-user", "root"))
        config.set('cluster', 'owner', self.options.get("owner", "root"))

        for s in services:
            config.add_section(s)
            config.set(s, "name", s)

            part = self.buildout[s]
            for key, value in part.items():
                config.set(s, key, value)

        config.write(open(cfg, 'wb'))

        ws = easy_install.working_set(
            ["isotoma.recipe.cluster"], pybin,
            [self.buildout["buildout"]['develop-eggs-directory'], self.buildout['buildout']['eggs-directory']])

        scripts = easy_install.scripts(
            [(self.name, "isotoma.recipe.cluster.ctl", "main")],
            ws, pybin, bindir, arguments='"%s"' % cfg,
            initialization=self.options.get("preamble", ""))

        return [os.path.join(bindir, self.name), cfg]
Example #10
0
    def createPythonScript(self, name, absolute_function, args=(), kw={}):
        """Create a python script using zc.buildout.easy_install.scripts

     * function should look like 'module.function', or only 'function'
       if it is a builtin function."""
        function = absolute_function.rsplit('.', 1)
        if len(function) == 1:
            module = '__builtin__'
            function, = function
        else:
            module, function = function
        path, filename = os.path.split(os.path.abspath(name))

        assert not isinstance(args, (six.string_types, dict)), args
        args = itertools.chain(map(repr, args),
                               map('%s=%r'.__mod__, six.iteritems(kw)))

        return easy_install.scripts([(filename, module, function)],
                                    self._ws,
                                    sys.executable,
                                    path,
                                    arguments=', '.join(args))[0]
Example #11
0
    def install(self):
        if self.__skip:
            self.__logger.info('skipped')
            return []

        from zc.buildout import easy_install
        import pkg_resources
        import sys
        ws = [pkg_resources.get_distribution(dist)
              for dist in ['unokit', 'oxt.tool', 'discover']]
        entrypoints = [(self.__name, 'oxt_tool', 'test_remotely')]
        arguments = '%r, %r, %r, %r'
        arguments = arguments % (self.__soffice,
                                 self.__discover,
                                 self.__extra_path,
                                 self.__logconf_path)
        if self.__python:
            python = self.__python
        else:
            python = sys.executable
        return easy_install.scripts(entrypoints,
                                    ws, python, self.__bindir,
                                    arguments=arguments)
Example #12
0
    def install(self):
        if self.__skip:
            self.__logger.info('skipped')
            return []

        from zc.buildout import easy_install
        import pkg_resources
        import sys
        ws = [pkg_resources.get_distribution(dist)
              for dist in ['unokit', 'oxt.tool']]
        if self.__in_proc:
            func = 'console_in_proc'
        else:
            func = 'console'
        entrypoints = [(self.__name, 'oxt_tool', func)]
        arguments = '%r' % self.__soffice
        if self.__python:
            python = self.__python
        else:
            python = sys.executable
        return easy_install.scripts(entrypoints,
                                    ws, python, self.__bindir,
                                    arguments=arguments)
Example #13
0
    def install_scripts(self, source_dir, project_dir):
        """ Install the control scripts that we need """

        # use the working set to correctly create the scripts with the correct
        # python path
        ws = self.working_set(extra=('isotoma.recipe.django',))[1]

        easy_install.scripts(
            [(
                "django-admin",
                "django.core.management",
                "execute_from_command_line"
            )],
            ws,
            self.options['executable'],
            self.options['bin-directory'],
            extra_paths = self.extra_paths
        )

        # this is a bit nasty
        # we need to add the project to the working set so we can import from it
        # so we're adding it's directory as an extra_path, as egg installing it
        # doesn't seem to be much success

        # install the project script ("manage.py")
        easy_install.scripts(
            [(
                self.options["control-script"],
                "django.core.management",
                "execute_from_command_line"
            )],
            ws,
            self.options['executable'],
            self.options['bin-directory'],
            arguments="sys.argv",
            initialization=self.initialization(),
            extra_paths = self.extra_paths
        )

        # install the wsgi script if required
        if self.options["wsgi"].lower() == "true":
            # the name of the wsgi script that will end up in bin-directory
            wsgi_name = "%s.%s" % (self.options["control-script"], "wsgi")
            # install the wsgi script
            # we need to reset the template, as we need a custom script, rather
            # than the standard buildout one

            # store the old one
            _script_template = easy_install.script_template

            # set our new template
            easy_install.script_template = easy_install.script_header + open(
                os.path.join(os.path.dirname(__file__), "templates/wsgi.tmpl")
            ).read() 

            project_real_path = os.path.realpath(project_dir)

            easy_install.scripts(
                [(
                    wsgi_name,
                    "django.core.wsgi",
                    "get_wsgi_application"
                )],
                ws,
                self.options['executable'],
                self.options['bin-directory'],
                arguments="",
                initialization=self.initialization(),
                extra_paths = [project_real_path] + self.extra_paths
            )
            zc.buildout.easy_install.script_template = _script_template

        # add the created scripts to the buildout installed stuff, so they get
        # removed correctly
        self.options.created(
            os.path.join(self.options["bin-directory"], "django-admin"),
            os.path.join(
                self.options["bin-directory"],
                self.options.get("control-script", "django")
            ),
        )
 def make_wrapper(self, name, module, func, path, **kwargs):
     reqs, ws = self.egg.working_set()
     easy_install.scripts([(name, module, func)], ws, sys.executable, path, **kwargs)
     self.installed.append(os.path.join(path, name))
Example #15
0
    def install_scripts(self, source_dir, project_dir):
        """ Install the control scripts that we need """

        # use the working set to correctly create the scripts with the correct
        # python path
        ws = self.working_set(extra=('isotoma.recipe.django', ))[1]

        easy_install.scripts([("django-admin", "django.core.management",
                               "execute_from_command_line")],
                             ws,
                             self.options['executable'],
                             self.options['bin-directory'],
                             extra_paths=self.extra_paths)

        # this is a bit nasty
        # we need to add the project to the working set so we can import from it
        # so we're adding it's directory as an extra_path, as egg installing it
        # doesn't seem to be much success

        # install the project script ("manage.py")
        easy_install.scripts([(self.options["control-script"],
                               "django.core.management", "execute_manager")],
                             ws,
                             self.options['executable'],
                             self.options['bin-directory'],
                             arguments="settings",
                             initialization=self.initialization(),
                             extra_paths=self.extra_paths)

        # install the wsgi script if required
        if self.options["wsgi"].lower() == "true":
            # the name of the wsgi script that will end up in bin-directory
            wsgi_name = "%s.%s" % (self.options["control-script"], "wsgi")
            # install the wsgi script
            # we need to reset the template, as we need a custom script, rather
            # than the standard buildout one

            # store the old one
            _script_template = easy_install.script_template

            # set our new template
            easy_install.script_template = easy_install.script_header + open(
                os.path.join(os.path.dirname(__file__),
                             "templates/wsgi.tmpl")).read()

            project_real_path = os.path.realpath(project_dir)

            easy_install.scripts(
                [(wsgi_name, "isotoma.recipe.django.wsgi", "main")],
                ws,
                self.options['executable'],
                self.options['bin-directory'],
                arguments="settings",
                initialization=self.initialization(),
                extra_paths=[project_real_path] + self.extra_paths)
            zc.buildout.easy_install.script_template = _script_template

        # add the created scripts to the buildout installed stuff, so they get
        # removed correctly
        self.options.created(
            os.path.join(self.options["bin-directory"], "django-admin"),
            os.path.join(self.options["bin-directory"],
                         self.options.get("control-script", "django")),
        )
Example #16
0
    def install(self):
        __, working_set = self.egg.working_set(self._packages())

        venv = self.options['virtualenv']
        venv_path = ''

        if venv:
            workon_home = os.environ.get('WORKON_HOME', '')
            if workon_home:
                envs = os.listdir(workon_home)
                if venv in envs:
                    bin_dir = 'Scripts' if sys.platform == 'win32' else 'bin'
                    venv_path = os.path.join(workon_home, venv, bin_dir,
                                             'activate_this.py')
                    if not os.path.isfile(venv_path):
                        logging.getLogger(self.name).error(
                            "part [%s], option virtualenv: activate_this.py "
                            "was not found in %s." %
                            (self.name, os.path.dirname(venv_path)))
                else:
                    logging.getLogger(self.name).error(
                        "part [%s]: no virtualenv named '%s' is available on "
                        "this system. Please create it or update the "
                        "virtualenv option." % (self.name, venv))
            else:
                logging.getLogger(self.name).error(
                    "The 'virtualenv' option is set in part [%(part)s] while "
                    "no WORKON_HOME environment variable is available. "
                    "Part [%(part)s] will be installed in the global python "
                    "environment." % {'part': self.name})

        _script_template = easy_install.script_template
        easy_install.script_template = easy_install.script_header + \
            ((venv_setup % venv_path) if venv_path else '') + \
            (self.script_template if self.script_template
                else _script_template.split('\n', 1)[1])
        # (we use split to strip the 1st line of _script_template, which is
        # the header)

        if self.options['script_path']:
            dest = os.path.normpath(
                os.path.join(self.options['root_dir'],
                             self.options['script_path']))
            dest_dir, dest_name = os.path.split(dest)
            if not os.path.isdir(dest_dir):
                os.makedirs(dest_dir)
        else:
            dest_dir = self.options['bin_dir']
            dest_name = self.name

        module_name = self.__class__.__module__.replace('recipes', 'scripts')
        script = easy_install.scripts(
            [(dest_name, module_name, 'main')],
            working_set,
            sys.executable,
            dest_dir,
            extra_paths=self.options['extra-paths'].split(';'),
            arguments=self._arguments(),
            initialization=self._initialization())

        easy_install.script_template = _script_template

        if self.options['script_path'] and sys.platform == 'win32':
            # on windows, the xxx-script.py must be renamed and the .exe
            # deleted if the script path is provided
            for s in script:
                if s.endswith('.py'):
                    # we rename the .py file, deleting the existing one if any
                    if os.path.exists(dest):
                        os.remove(dest)
                    os.rename(s, dest)
                else:
                    # we remove the .exe file
                    os.remove(s)
            script = [dest]

        return script
    def install(self):
        options = self.options
        location = options['location']

        reqs, ws = self.egg.working_set(['plone.recipe.alltests'])

        packages = []
        paths = {}
        for dist in ws.by_key.values():
            name = dist.project_name
            packages.append(name)
            paths[name] = dist.location

        excludes = [re.compile(e) for e in self.exclude]
        includes = [re.compile(e) for e in self.include]

        filtered_packages = []
        for p in list(set(packages) - EXCLUDE_PACKAGES):
            match = False
            if self.default_policy == 'include':
                for e in excludes:
                    if e.search(p) is not None:
                        match = True
                        break
                if not match:
                    filtered_packages.append(p)
            elif self.default_policy == 'exclude':
                for i in includes:
                    if i.search(p) is not None:
                        match = True
                        break
                if match:
                    filtered_packages.append(p)
        packages = filtered_packages

        # Allow to map distribution names to different package names
        pmap = dict()
        package_map = options.get('package-map', '').strip()
        if package_map:
            pmap = self.buildout[package_map]

        for k, v in pmap.items():
            if k in packages:
                packages.remove(k)
                packages.append(v)
                paths[v] = paths[k]
                del paths[k]
        packages.sort()

        # Allow to group multiple packages into one test run
        groups = dict()
        groups_section = options.get('groups', '').strip()
        if groups_section:
            data = self.buildout[groups_section]
            for k, v in data.items():
                if self.default_policy == 'include':
                    if k in self.exclude_groups:
                        for p in v.split():
                            if p in packages:
                                packages.remove(p)
                    else:
                        groups[k] = v.split()
                elif self.default_policy == 'exclude' and k in self.include_groups:
                    groups[k] = v.split()

        easy_install.scripts(
            [(self.name, 'plone.recipe.alltests.runner', 'main')],
            ws, options['executable'], options['bin-directory'],
            arguments=dict(
                packages=packages,
                testscript=self.testscript,
                paths=paths,
                groups=groups,
            ),
        )

        return location