Ejemplo n.º 1
0
-----------------------

The 'init' command
"""
import os
import sys
import shutil
import tempfile
from virtstrap.argparse import ArgumentParser
from virtstrap import commands
from virtstrap import constants
from virtstrap.options import base_options_to_args
from virtstrap.requirements import RequirementSet
from virtstrap_system.loaders import call_project_command

parser = ArgumentParser()
parser.add_argument('project_dir',
                    metavar='PROJECT_DIR',
                    help="project's root directory",
                    nargs='?',
                    default='.')


def process_plugins_config(raw_plugins):
    requirement_set = RequirementSet.from_config_data(raw_plugins)
    return requirement_set


class InitializeCommand(commands.ProjectCommand):
    name = 'init'
    parser = parser
Ejemplo n.º 2
0
-----------------------

The 'init' command
"""
import os
import sys
import shutil
import tempfile
from virtstrap.argparse import ArgumentParser
from virtstrap import commands
from virtstrap import constants
from virtstrap.options import base_options_to_args
from virtstrap.requirements import RequirementSet
from virtstrap_system.loaders import call_project_command

parser = ArgumentParser()
parser.add_argument('project_dir', metavar='PROJECT_DIR',
        help="project's root directory",
        nargs='?', default='.')

def process_plugins_config(raw_plugins):
    requirement_set = RequirementSet.from_config_data(raw_plugins)
    return requirement_set

class InitializeCommand(commands.ProjectCommand):
    name = 'init'
    parser = parser
    description = 'Bootstraps a virtstrap virtual environment'

    def run(self, project, options, raw_args=None, use_injected_project=False, 
            **kwargs):
Ejemplo n.º 3
0
virtstrap.commands.install
--------------------------

The 'install' command
"""
import os
import tempfile
import subprocess
from contextlib import contextmanager
from virtstrap.argparse import ArgumentParser
from virtstrap import commands
from virtstrap import constants
from virtstrap.requirements import RequirementSet
from virtstrap.locker import *

parser = ArgumentParser()
parser.add_argument('env_file',
                    metavar='FILE',
                    help="file to write extra environment")


class EnvironmentCommand(commands.ProjectCommand):
    name = 'environment'
    description = "Writes extra environment variables to a file"
    parser = parser

    def run(self, project, options, **kwargs):
        environment_vars = self.get_environment_vars(project)
        self.write_environment_vars_to_file(options, environment_vars)

    def process_environment_config(self, raw_environment):
Ejemplo n.º 4
0
import json
from virtstrap.argparse import ArgumentParser
from virtstrap import commands
from virtstrap.log import logger

parser = ArgumentParser()
parser.add_argument('--as-json', action='store_true',
        dest='as_json')

class CommandsCommand(commands.Command):
    name = 'commands'
    description = 'Lists commands (Excludes self from commands)'
    parser = parser
    events = []

    def run(self, options, **kwargs):
        collected_commands = self.collect_commands()
        if options.as_json:
            self.display_json(collected_commands)
        else:
            self.display_readable(collected_commands)

    def collect_commands(self):
        collected = []
        for command_name, command in commands.registry.commands_iter():
            if command_name == self.name:
                continue
            collected.append(dict(name=command.name, 
                description=command.description))
        return collected
Ejemplo n.º 5
0
import json
from virtstrap.argparse import ArgumentParser
from virtstrap import commands
from virtstrap.log import logger

parser = ArgumentParser()
parser.add_argument('--as-json', action='store_true', dest='as_json')


class CommandsCommand(commands.Command):
    name = 'commands'
    description = 'Lists commands (Excludes self from commands)'
    parser = parser
    events = []

    def run(self, options, **kwargs):
        collected_commands = self.collect_commands()
        if options.as_json:
            self.display_json(collected_commands)
        else:
            self.display_readable(collected_commands)

    def collect_commands(self):
        collected = []
        for command_name, command in commands.registry.commands_iter():
            if command_name == self.name:
                continue
            collected.append(
                dict(name=command.name, description=command.description))
        return collected
Ejemplo n.º 6
0
virtstrap.commands.install
--------------------------

The 'install' command
"""
import os
import tempfile
import subprocess
from contextlib import contextmanager
from virtstrap.argparse import ArgumentParser
from virtstrap import commands
from virtstrap import constants
from virtstrap.requirements import RequirementSet
from virtstrap.locker import *

parser = ArgumentParser()
parser.add_argument('env_file', metavar='FILE',
        help="file to write extra environment")

class EnvironmentCommand(commands.ProjectCommand):
    name = 'environment'
    description = "Writes extra environment variables to a file"
    parser = parser

    def run(self, project, options, **kwargs):
        environment_vars = self.get_environment_vars(project)
        self.write_environment_vars_to_file(options, environment_vars)

    def process_environment_config(self, raw_environment):
        project = self.project
        raw_environment = raw_environment or {}