Exemplo n.º 1
0
from vee.commands.main import command, argument
from vee.network import Client

@command(
    argument('host'),
    argument('port', type=int, default=38123),
)
def client(args):

    c = Client(args.assert_home(), (args.host, args.port))
    c.run_forever()
Exemplo n.º 2
0
from vee import log
from vee.cli import style, style_error, style_note
from vee.commands.main import command, argument
from vee.git import GitRepo, normalize_git_url
from vee.packageset import PackageSet

default_messages = {
    0: 'major changes  (e.g. backwards incompatible)',
    1: 'minor changes (e.g. extended features)',
    2: 'patch-level changes (e.g. bug fixes)',
    None: 'micro changes (e.g. config or build)',
}


@command(
    argument('--major', action='store_const', dest='semver_level', const=0),
    argument('--minor', action='store_const', dest='semver_level', const=1),
    argument('--patch', action='store_const', dest='semver_level', const=2),
    argument('--micro', action='store_true'),
    argument('-r', '--repo'),
    argument('-m', '--message'),
    help='commit changes to environment repo',
    group='development',
)
def commit(args):

    home = args.assert_home()
    repo = home.get_repo(args.repo)

    if not repo.status():
        log.error('Nothing to commit.')
Exemplo n.º 3
0
from vee.commands.main import command, argument
from vee.subproc import call, which


def parse_version(x):
    parts = x.split('.')
    for i, x in enumerate(parts):
        try:
            parts[i] = int(x)
        except ValueError:
            pass
    return tuple(parts)


@command(
    argument('--ping', action='store_true', help='print "pong", and exit'),
    argument('--version',
             action='store_true',
             help='print VEE\'s version, and exit'),
    argument('--revision',
             action='store_true',
             help='print VEE\'s revision, and exit'),
    help='perform a self-check',
    usage='vee doctor [--ping,--version,--revision]',
    group='setup',
)
def doctor(args):
    """Perform self-checks to make sure VEE is OK."""

    if args.ping:
        print('pong')
Exemplo n.º 4
0
   or: vee develop clone URL [NAME]
   or: vee develop add PATH [NAME]
   or: vee develop rm PATTERN
   or: vee develop find PATH
   or: vee develop install NAME
   or: vee develop rescan [NAME ...]
   or: vee develop setenv NAME KEY=value [...]
   or: vee develop list [--availible] [--environ]
""".strip(),
    group='development',
)
def develop(args):
    pass


@develop.subcommand(argument('-a', '--availible', action='store_true'),
                    argument('-e',
                             '--environ',
                             dest='show_environ',
                             action='store_true'),
                    argument('glob', nargs='?'),
                    name='list',
                    help='list all installed or availible tools')
def list_(args):

    home = args.assert_home()

    if args.availible:
        for req, url in iter_availible_requirements(home):
            log.info(style_note(req.name, str(req)))
        return
Exemplo n.º 5
0
import os
import re
import sys

from vee._vendor import vendor_path, bootstrap_environ
from vee.commands.main import command, argument, group
from vee.environment import Environment
from vee.envvars import guess_envvars, render_envvars
from vee.exceptions import NotInstalled
from vee.packageset import PackageSet
from vee.requirements import Requirements


@command(
    argument('--export',
             action='store_true',
             help='export the environment instead of executing in it'),
    argument('--prefix',
             action='store_true',
             help='print the prefixes that would be linked together'),
    argument(
        '-R',
        '--requirements',
        action='append',
        help=
        'requirements or requirements files to include; may be comma separated'
    ),
    argument(
        '-r',
        '--repo',
        action='append',
Exemplo n.º 6
0
from vee.cli import style, style_note, style_warning
from vee.commands.main import command, argument, group
from vee.environment import Environment


@command(
    argument('--all', action='store_true', help='update all repos'),
    argument('--force',
             action='store_true',
             help='force checkout, even if not fast-forward'),
    argument('-r', '--repo', action='append', dest='repos'),
    help='update repos',
    acquire_lock=True,
    group='workflow',
)
def update(args):
    """Update the environment repository (via `git pull`). This will fail if
    your repositories are dirty, or have forked from their remotes.
    """

    home = args.assert_home()

    if args.all:
        repos = list(home.iter_repos())
    else:
        repos = [home.get_repo(x)
                 for x in args.repos] if args.repos else [home.get_repo()]

    success = True

    for repo in repos:
Exemplo n.º 7
0
Arquivo: git.py Projeto: westernx/vee
from vee.cli import style_error
from vee.commands.main import command, argument
from vee.subproc import call
from vee.utils import makedirs


@command(
    argument('-r', '--repo', help='which repo to use'),
    argument('--stree', action='store_true', help='launch SourceTree'),
    help='run a git command in a repository',
    parse_known_args=True,
    group='plumbing',
    usage='vee git [-r REPO] COMMAND+',
)
def git(args, *command):
    """Run a ``git`` command on a environment repository's git repository.
    (Sorry for the name collision.)

    e.g.::

        $ vee git -r primary status
        On branch master
        Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
          (use "git pull" to update your local branch)
        nothing to commit, working directory clean

    """

    home = args.assert_home()
    repo = home.get_env_repo(args.repo)
Exemplo n.º 8
0
        # Change a repo's url and branch
        $ vee repo set --branch unstable myrepo

        # Delete a repo.
        $ vee repo delete myrepo

        # List all repos.
        $ vee repo list

    """
    # Never goes here.
    pass


@repo.subcommand(argument('--default',
                          action='store_true',
                          help='this repo is the default'),
                 argument('--remote',
                          help='git remote to track',
                          default='origin'),
                 argument('--branch', help='git branch to track'),
                 argument('name', nargs='?'),
                 help='create a blank repository')
def init(args, is_set=False):
    home = args.assert_home()
    home.create_repo(
        name=args.name,
        url=None,
        remote=args.remote,
        branch=args.branch,
        is_default=args.default,
Exemplo n.º 9
0
Arquivo: gc.py Projeto: westernx/vee
def delete_environment(con, id_):
    con.execute('DELETE FROM links WHERE environment_id = ?', [id_])
    con.execute('DELETE FROM environments WHERE id = ?', [id_])


def delete_package(con, id_):
    con.execute(
        'DELETE FROM package_dependencies WHERE depender_id = ? or dependee_id = ?',
        [id_, id_])
    con.execute('DELETE FROM links WHERE package_id = ?', [id_])
    con.execute('DELETE FROM shared_libraries WHERE package_id = ?', [id_])
    con.execute('DELETE FROM packages WHERE id = ?', [id_])


@command(
    argument('-e', '--prune-environments', action='store_true'),
    argument('--keep-latest', type=int, default=10),
    argument('-p', '--prune-orphaned-packages', action='store_true'),
    argument('-n', '--dry-run', action='store_true'),
    group='plumbing',
    help='cleanup VEE',
)
def gc(args):

    home = args.assert_home()
    con = home.db.connect()

    with con:

        repo_ids = {}
        for row in con.execute('SELECT id, name from repositories'):
Exemplo n.º 10
0
import re

from vee.cli import style, style_error, style_note
from vee.commands.main import command, argument
from vee.git import GitRepo, normalize_git_url


@command(
    argument('-r', '--repo'),
    help='push changes to environment repo',
    group='development',
)
def push(args):
    home = args.assert_home()

    # TODO: push all tools, or at least check them.

    repo = home.get_repo(args.repo)
    repo.git('push')
Exemplo n.º 11
0
import os
import shlex

from vee.cli import style, style_error, style_note
from vee.commands.main import command, argument
from vee.git import GitRepo, normalize_git_url
from vee.subproc import call
from vee import log


@command(
    argument('-r', '--repo', nargs='?'),
    help='open manifest.txt in $EDITOR',
    group='development',
)
def edit(args):

    home = args.assert_home()
    repo = home.get_repo(args.repo)

    cmd = []
    cmd.extend(shlex.split(os.environ.get('EDITOR', 'vim')))
    cmd.append(os.path.join(repo.work_tree, 'manifest.txt'))

    log.debug(cmd, verbosity=1)

    os.execvp(cmd[0], cmd)
Exemplo n.º 12
0
import os
import stat

from vee.cli import style
from vee.commands.main import command, argument
from vee.home import PRIMARY_REPO
from vee import libs
from vee import log


@command(
    argument('-n', '--dry-run', action='store_true'),
    argument('--scan',
             action='store_true',
             help='look for installed libraires'),
    argument('--rescan', action='store_true', help='redo previous scans'),
    argument('--spec', default='AUTO'),
    argument('path', nargs='?'),
    help='relocate a package',
    group='plumbing',
)
def relocate(args):

    home = args.assert_home()

    if args.scan or args.rescan:
        rows = list(
            home.db.execute('''SELECT id, install_path FROM packages
            ORDER BY created_at DESC
        '''))
        seen_paths = set()
Exemplo n.º 13
0
import argparse
import os

from vee import log
from vee.cli import style, style_note
from vee.commands.main import command, argument
from vee.environment import Environment
from vee.exceptions import AlreadyInstalled, AlreadyLinked, print_cli_exc
from vee.manifest import Manifest
from vee.package import Package
from vee.packageset import PackageSet


@command(
    argument('--reinstall', action='store_true'),
    argument('--no-install', action='store_true'),
    argument('--force', action='store_true'),
    argument('--raw',
             action='store_true',
             help='arguments are raw directories'),
    argument('-r', '--repo'),
    argument('-e', '--environment'),
    argument('-d', '--directory'),
    argument('--subset', action='append', help=argparse.SUPPRESS),
    argument('requirements', nargs='...'),
    help='link a package, or manifest.txt, into an environment',
    acquire_lock=True,
    group='plumbing',
    usage='vee link ENVIRON (REQUIREMENT [OPTIONS])+',
)
def link(args):
Exemplo n.º 14
0
from vee.commands.main import command, argument, group
from vee.environment import Environment


@command(
    group(
        argument('--get', action='store_true',
                 help='get given keys (default)'),
        argument('--list', action='store_true', help='list all variables set'),
        argument('--set', action='store_true', help='set key-value pairs'),
        argument('--delete', action='store_true', help='delete given keys'),
        argument('--clear', action='store_true', help='clear all config'),
        exclusive=True,
    ),
    argument('values', nargs='...', help='values for getting, setting, etc.'),
    # We have no help so the command doesn't show up in main help.
    # help='manage the configuration',
)
def config(args):
    """Manipulate the key-value config.

    THE CONFIG SYSTEM IS CURRENTLY UNUSED.

    """

    args.assert_home()
    config = args.home.config

    if args.list:
        for k, v in sorted(config.iteritems()):
            print '%s=%s' % (k, v)
Exemplo n.º 15
0
from vee.commands.main import command, argument, group


@command(
    argument('--all', action='store_true', help='upgrade all repositories'),
    argument('-u',
             '--update',
             action='store_true',
             help='update before upgrading'),
    argument('--dirty',
             action='store_true',
             help='build even when work tree is dirty'),
    argument('--relink', action='store_true', help='relink packages'),
    argument('--reinstall', action='store_true', help='reinstall packages'),
    argument('--no-deps', action='store_true', help='dont touch dependencies'),
    argument('-f', '--force-branch-link', action='store_true'),
    argument('-r', '--repo', action='append', dest='repos'),
    argument('subset', nargs='*'),
    help=
    'upgrade packages specified by repositories, and link into environments',
    acquire_lock=True,
    group='workflow')
def upgrade(args):
    """Install packages and link into environments, as specified by repositories.
    """

    home = args.assert_home()

    if args.all:
        repos = list(home.iter_repos())
    else:
Exemplo n.º 16
0
def describe(pkg, cache, depth=0):

    print(('    ' * depth) + style(pkg.name, 'blue'), pkg.id,
          style('***' if pkg.id in cache else str(pkg), faint=True))

    if pkg.id in cache:
        return
    cache[pkg.id] = pkg

    for dep in pkg.dependencies:
        dep.resolve_existing()
        describe(dep, cache, depth + 1)


@command(
    argument('-e', '--environments', action='store_true'),
    name='list',
)
def list_(args):

    if args.environments:
        list_environments(args)
        return
    else:
        list_packages(args)


def list_environments(args):

    home = args.assert_home()
    con = home.db.connect()
Exemplo n.º 17
0
Arquivo: add.py Projeto: westernx/vee
import os
import re

from vee.cli import style, style_error, style_note, style_warning
from vee.commands.main import command, argument
from vee.git import GitRepo, normalize_git_url
from vee.packageset import PackageSet
from vee.package import Package
from vee.utils import guess_name, checksum_file
from vee import log


@command(
    argument('--update',
             action='store_true',
             help='update all repos themselves'),
    argument('--bake-installed',
             action='store_true',
             help='bake all installed revisions'),
    argument('--checksum',
             action='store_true',
             help='checksum existing packages'),
    argument('--init',
             action='store_true',
             help='create if not found in requirements'),
    argument('--repo'),
    argument('package', nargs='?', default='.'),
    help='record changes to dev packages in environment repo',
    group='development',
)
def add(args):
Exemplo n.º 18
0
import tempfile
import stat

from vee.commands.main import command, argument, group
from vee.environment import Environment
from vee.cli import style, style_note
from vee import log
from vee.package import Package
from vee.utils import makedirs, guess_name, HashingWriter

PLATFORM_DEPENDENT_EXTS = set(('.so', '.exe', '.dylib', '.a'))
PLATFORM_TAG = sys.platform.strip('2')


@command(
    argument('--no-deps', action='store_true', help='skip dependencies'),
    argument('-f', '--force', action='store_true', help='overwrite existing?'),
    argument('-v', '--verbose', action='store_true'),
    argument('-u', '--url', help='base of URL to output for requirements.txt'),
    argument('-d', '--dir', required=True, help='output directory'),
    argument('packages', nargs='+', help='names or URLs'),
)
def repackage(args):

    home = args.assert_home()
    con = home.db.connect()

    makedirs(args.dir)

    todo = args.packages
    seen = set()
Exemplo n.º 19
0
Arquivo: init.py Projeto: westernx/vee
from vee.cli import style, style_error
from vee.commands.main import command, argument
from vee.home import PRIMARY_REPO


@command(
    argument('url', nargs='?', help='URL of new repository to clone'),
    argument('name', nargs='?', help='name for new repository'),
    help='initialize VEE\'s home',
    usage='vee init URL',
    group='setup',
)
def init(args):
    """Initialize the structures on disk before any other commands, and
    optionally setup the first environment repository.

    E.g.:

        vee init [email protected]:westernx/vee-repo primary

    This is the same as:

        vee init
        vee repo clone [email protected]:westernx/vee-repo primary


    """

    try:
        args.home.init()
        print 'Initialized %s' % args.home.root
Exemplo n.º 20
0
import argparse

from vee.cli import style
from vee.commands.main import command, argument
from vee.exceptions import AlreadyInstalled
from vee.packageset import PackageSet
from vee.requirements import Requirements


@command(
    argument('--force', action='store_true', help='force install over old package'),
    argument('requirements', nargs='...', help=argparse.SUPPRESS),
    help='install a package; low-level',
    usage='vee install [--force] {PACKAGE [OPTIONS], REQUIREMENTS_FILE}+',
    acquire_lock=True,
    group='plumbing',
)
def install(args):
    """Install the given requirements without linking them into an environment.
    This is a low-level command, and is generally unused.

    Examples:

        # Install a single package.
        vee install [email protected]:westernx/sgmock

        # Install multiple packages.
        vee install [email protected]:westernx/sgmock [email protected]:westernx/sgsession \\
            http:/example.org/path/to/tarball.tgz --make-install

        # Install from a requirement set.
Exemplo n.º 21
0
                             fg='green',
                             reset=True)
    elif remote:
        print indent + style_warning('%s %s behind%s by %d commit%s%s' % (
            local_name,
            local_verb,
            ' ' + remote_name if remote_name else '',
            remote,
            's' if remote > 1 else '',
            '; ' + behind_action if behind_action else '.',
        ))


@command(
    argument('--all-dev',
             action='store_true',
             help='include all dev packages, not just those in repos'),
    argument('--fetch', action='store_true', help='fetch dev packages'),
    argument('-v', '--verbose', action='count'),
    argument('-r', '--repo'),
    argument('names', nargs='*'),
)
def status(args):

    home = args.assert_home()

    env_repo = home.get_env_repo(args.repo)
    pkg_set = PackageSet(home=home)

    by_name = {}