How to use the lektor.utils.portable_popen function in Lektor

To help you get started, we’ve selected a few Lektor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ulope / pyformat.info / vendor / lektor / lektor / devserver.py View on Github external
def start(self):
        if self.watcher is not None:
            return
        from lektor import admin
        admin = os.path.dirname(admin.__file__)
        portable_popen(['npm', 'install', '.'], cwd=admin).wait()

        self.watcher = portable_popen([os.path.join(
            admin, 'node_modules/.bin/webpack'), '--watch'],
            cwd=os.path.join(admin, 'static'))
github lektor / lektor-archive / lektor / packages.py View on Github external
# Step 1: generate egg info and link us into the target folder.
    rv = portable_popen([
        sys.executable,
        '-m', 'pip',
        'install', '--editable', path,
        '--install-option=--install-dir=%s' % package_root,
        '--no-deps'
    ], env=env).wait()
    if rv != 0:
        raise RuntimeError('Failed to install local package')

    # Step 2: generate the egg info into a temp folder to find the
    # requirements.
    tmp = tempfile.mkdtemp()
    try:
        rv = portable_popen([
            sys.executable,
            'setup.py', '--quiet', 'egg_info', '--quiet',
            '--egg-base', tmp
        ], cwd=path).wait()
        dirs = os.listdir(tmp)
        if rv != 0 or len(dirs) != 1:
            raise RuntimeError('Failed to create egg info for local package.')
        requires = os.path.join(tmp, dirs[0], 'requires.txt')

        # We have dependencies, install them!
        if os.path.isfile(requires):
            download_and_install_package(package_root,
                                         requirements_file=requires)
    finally:
        shutil.rmtree(tmp)
github lektor / lektor-archive / lektor / packages.py View on Github external
"""This downloads and installs a specific version of a package."""
    # XXX: windows
    env = dict(os.environ)

    args = [
        sys.executable,
        '-m', 'pip', 'install', '--target', package_root,
    ]

    if package is not None:
        args.append('%s%s%s' % (package, version and '==' or '',
                                version or ''))
    if requirements_file is not None:
        args.extend(('-r', requirements_file))

    rv = portable_popen(args, env=env).wait()
    if rv != 0:
        raise RuntimeError('Failed to install dependency package.')
github ulope / pyformat.info / vendor / lektor / lektor / packages.py View on Github external
def install_local_package(package_root, path):
    """This installs a local dependency of a package."""
    # XXX: windows
    env = dict(os.environ)
    env['PYTHONPATH'] = package_root

    # Step 1: generate egg info and link us into the target folder.
    rv = portable_popen([
        sys.executable,
        '-m', 'pip',
        'install', '--editable', path,
        '--install-option=--install-dir=%s' % package_root,
        '--no-deps'
    ], env=env).wait()
    if rv != 0:
        raise RuntimeError('Failed to install local package')

    # Step 2: generate the egg info into a temp folder to find the
    # requirements.
    tmp = tempfile.mkdtemp()
    try:
        rv = portable_popen([
            sys.executable,
            'setup.py', '--quiet', 'egg_info', '--quiet',
github ulope / pyformat.info / vendor / lektor / lektor / packages.py View on Github external
# Step 1: generate egg info and link us into the target folder.
    rv = portable_popen([
        sys.executable,
        '-m', 'pip',
        'install', '--editable', path,
        '--install-option=--install-dir=%s' % package_root,
        '--no-deps'
    ], env=env).wait()
    if rv != 0:
        raise RuntimeError('Failed to install local package')

    # Step 2: generate the egg info into a temp folder to find the
    # requirements.
    tmp = tempfile.mkdtemp()
    try:
        rv = portable_popen([
            sys.executable,
            'setup.py', '--quiet', 'egg_info', '--quiet',
            '--egg-base', tmp
        ], cwd=path).wait()
        dirs = os.listdir(tmp)
        if rv != 0 or len(dirs) != 1:
            raise RuntimeError('Failed to create egg info for local package.')
        requires = os.path.join(tmp, dirs[0], 'requires.txt')

        # We have dependencies, install them!
        if os.path.isfile(requires):
            download_and_install_package(package_root,
                                         requirements_file=requires)
    finally:
        shutil.rmtree(tmp)
github ulope / pyformat.info / vendor / lektor / lektor / packages.py View on Github external
"""This downloads and installs a specific version of a package."""
    # XXX: windows
    env = dict(os.environ)

    args = [
        sys.executable,
        '-m', 'pip', 'install', '--target', package_root,
    ]

    if package is not None:
        args.append('%s%s%s' % (package, version and '==' or '',
                                version or ''))
    if requirements_file is not None:
        args.extend(('-r', requirements_file))

    rv = portable_popen(args, env=env).wait()
    if rv != 0:
        raise RuntimeError('Failed to install dependency package.')
github lektor / lektor-archive / lektor / plugins / less.py View on Github external
def build_artifact(self, artifact):
        ctx = get_ctx()
        source_out = self.build_state.make_named_temporary('less')
        map_out = self.build_state.make_named_temporary('less-sourcemap')
        here = os.path.dirname(self.source.source_filename)

        cmdline = ['lessc', '--no-js', '--include-path=%s' % here,
                   '--source-map=%s' % map_out,
                   self.source.source_filename,
                   source_out]

        reporter.report_debug_info('lessc cmd line', cmdline)

        proc = portable_popen(cmdline)
        if proc.wait() != 0:
            raise RuntimeError('lessc failed')

        with open(map_out) as f:
            dep_base = os.path.dirname(map_out)
            for dep in json.load(f).get('sources') or ():
                ctx.record_dependency(os.path.join(dep_base, dep))

        artifact.replace_with_file(source_out)
github lektor / lektor-archive / lektor / packages.py View on Github external
def install_local_package(package_root, path):
    """This installs a local dependency of a package."""
    # XXX: windows
    env = dict(os.environ)
    env['PYTHONPATH'] = package_root

    # Step 1: generate egg info and link us into the target folder.
    rv = portable_popen([
        sys.executable,
        '-m', 'pip',
        'install', '--editable', path,
        '--install-option=--install-dir=%s' % package_root,
        '--no-deps'
    ], env=env).wait()
    if rv != 0:
        raise RuntimeError('Failed to install local package')

    # Step 2: generate the egg info into a temp folder to find the
    # requirements.
    tmp = tempfile.mkdtemp()
    try:
        rv = portable_popen([
            sys.executable,
            'setup.py', '--quiet', 'egg_info', '--quiet',
github lektor / lektor / lektor / imagetools.py View on Github external
if mode == ThumbnailMode.STRETCH:
        resize_key += '!'

    cmdline = [im, source_image, '-auto-orient']
    if mode == ThumbnailMode.CROP:
        cmdline += ['-resize', resize_key + '^',
                    '-gravity', 'Center',
                    '-extent', resize_key]
    else:
        cmdline += ['-resize', resize_key]

    cmdline += ['-quality', str(quality), dst_filename]

    reporter.report_debug_info('imagemagick cmd line', cmdline)
    portable_popen(cmdline).wait()
github lektor / lektor-archive / lektor / packages.py View on Github external
def register_package(path):
    """Registers the plugin at the given path."""
    portable_popen([
        sys.executable,
        'setup.py', 'register'
    ], cwd=path).wait()