示例#1
0
文件: deploy.py 项目: mcanthony/dxr
    def build(self, rev):
        """Create and return the path of a new directory containing a new
        deployment of the given revision of the source.

        If it turns out we shouldn't deploy this build after all (perhaps
        because some additional data yielded by an asynchronous build process
        isn't yet available in the new format) but there hasn't been a
        programming error that would warrant a more serious exception, raise
        ShouldNotDeploy.

        """
        VENV_NAME = 'virtualenv'
        new_build_path = mkdtemp(prefix='%s-' % rev[:6],
                                 dir=join(self.base_path, 'builds'))
        try:
            with cd(new_build_path):
                # Make a fresh, blank virtualenv:
                run('virtualenv -p {python} --no-site-packages {venv_name}',
                    python=self.python_path,
                    venv_name=VENV_NAME)

                # Check out the source, and install DXR and dependencies:
                run('git clone {repo} 2>/dev/null', repo=self.repo)
                with cd('dxr'):
                    run('git checkout -q {rev}', rev=rev)

                    old_format = file_text('%s/dxr/dxr/format' % self._deployment_path()).rstrip()
                    new_format = file_text('dxr/format').rstrip()
                    self._format_changed_from = (old_format
                                                 if old_format != new_format
                                                 else None)
                    self._check_deployed_trees(old_format, new_format)

                    run('git submodule update -q --init --recursive')
                    # Make sure a malicious server didn't slip us a mickey. TODO:
                    # Does this recurse into submodules?
                    run('git fsck --no-dangling')

                    # Install stuff, using the new copy of peep from the checkout:
                    python = join(new_build_path, VENV_NAME, 'bin', 'python')
                    run('{python} ./peep.py install -r requirements.txt',
                        python=python)
                    # Compile nunjucks templates and cachebust static assets:
                    run('make static &> /dev/null')
                    # Quiet the complaint about there being no matches for *.so:
                    run('{python} setup.py install 2>/dev/null', python=python)

                # After installing, you always have to re-run this, even if we
                # were reusing a venv:
                run('virtualenv --relocatable {venv}',
                    venv=join(new_build_path, VENV_NAME))

                run('chmod 755 .')  # mkdtemp uses a very conservative mask.
        except Exception:
            rmtree(new_build_path)
            raise
        return new_build_path
示例#2
0
文件: deploy.py 项目: mcphail/dxr
    def build(self, rev):
        """Create and return the path of a new directory containing a new
        deployment of the given revision of the source.

        If it turns out we shouldn't deploy this build after all (perhaps
        because some additional data yielded by an asynchronous build process
        isn't yet available in the new format) but there hasn't been a
        programming error that would warrant a more serious exception, raise
        ShouldNotDeploy.

        """
        VENV_NAME = 'virtualenv'
        new_build_path = mkdtemp(prefix='%s-' % rev[:6],
                                 dir=join(self.base_path, 'builds'))
        try:
            with cd(new_build_path):
                # Make a fresh, blank virtualenv:
                run('virtualenv -p {python} --no-site-packages {venv_name}',
                    python=self.python_path,
                    venv_name=VENV_NAME)

                # Check out the source, and install DXR and dependencies:
                run('git clone {repo} 2>/dev/null', repo=self.repo)
                with cd('dxr'):
                    run('git checkout -q {rev}', rev=rev)

                    old_format = file_text('%s/dxr/dxr/format' % self._deployment_path()).rstrip()
                    new_format = file_text('dxr/format').rstrip()
                    self._format_changed_from = (old_format
                                                 if old_format != new_format
                                                 else None)
                    self._check_deployed_trees(old_format, new_format)

                    run('git submodule update -q --init --recursive')
                    # Make sure a malicious server didn't slip us a mickey. TODO:
                    # Does this recurse into submodules?
                    run('git fsck --no-dangling')

                    # Install stuff, using the new copy of peep from the checkout:
                    python = join(new_build_path, VENV_NAME, 'bin', 'python')
                    run('{python} ./peep.py install -r requirements.txt',
                        python=python)
                    # Compile nunjucks templates:
                    run('make templates &> /dev/null')
                    # Quiet the complaint about there being no matches for *.so:
                    run('{python} setup.py install 2>/dev/null', python=python)

                # After installing, you always have to re-run this, even if we
                # were reusing a venv:
                run('virtualenv --relocatable {venv}',
                    venv=join(new_build_path, VENV_NAME))

                run('chmod 755 .')  # mkdtemp uses a very conservative mask.
        except Exception:
            rmtree(new_build_path)
            raise
        return new_build_path
示例#3
0
文件: wsgi.py 项目: Darshnik/dxr
def application(environ, start_response):
    """Pull the config file path out of an env var, and then instantiate the
    WSGI app as normal.

    This prefers the Apache SetEnv sort of environment; but if that's missing,
    try the process-level env var instead since it's easier to set for some
    users, like those using Stackato.

    """
    try:
        config_path = environ['DXR_CONFIG']
    except KeyError:
        # Not found in WSGI env. Try process env:
        # If this still fails, this is a fatal error.
        config_path = os.environ['DXR_CONFIG']
    return make_app(Config(file_text(config_path),
                           relative_to=dirname(config_path)))(environ,
                                                              start_response)
示例#4
0
文件: testing.py 项目: jay-z007/dxr
 def config_input(cls, config_dir_path):
     return file_text(join(cls._config_dir_path, 'dxr.config'))
示例#5
0
 def config_input(cls, config_dir_path):
     return file_text(join(cls._config_dir_path, 'dxr.config'))