diff options
| author | Scott Moser <smoser@ubuntu.com> | 2016-04-04 12:07:19 -0400 |
|---|---|---|
| committer | Scott Moser <smoser@ubuntu.com> | 2016-04-04 12:07:19 -0400 |
| commit | 7d8a3194552387fa9e21216bcd9a3bfc76fa2b04 (patch) | |
| tree | c8dc45b013208a4e5e09e6ade63b3b5994f80aa3 /tools/tox-venv | |
| parent | 93f5af9f5075a416c65c1d0350c374e16f32f0d5 (diff) | |
| parent | 210b041b2fead7a57af91f60a6f89d9e5aa1ed4a (diff) | |
| download | vyos-cloud-init-7d8a3194552387fa9e21216bcd9a3bfc76fa2b04.tar.gz vyos-cloud-init-7d8a3194552387fa9e21216bcd9a3bfc76fa2b04.zip | |
merge with trunk
Diffstat (limited to 'tools/tox-venv')
| -rwxr-xr-x | tools/tox-venv | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tools/tox-venv b/tools/tox-venv new file mode 100755 index 00000000..76ed5076 --- /dev/null +++ b/tools/tox-venv @@ -0,0 +1,42 @@ +#!/bin/sh + +error() { echo "$@" 1>&2; } +fail() { [ $# -eq 0 ] || error "$@"; exit 1; } +Usage() { + cat <<EOF +Usage: ${0##*/} tox-environment [command [args]] + run command with provided arguments in the provided tox environment + command defaults to \${SHELL:-/bin/sh}. + + invoke with '--list' to show available environments +EOF +} +list_toxes() { + local td="$1" pre="$2" d="" + ( cd "$tox_d" && + for d in *; do [ -f "$d/bin/activate" ] && echo "${pre}$d"; done) +} + +[ $# -eq 0 ] && { Usage 1>&2; exit 1; } +[ "$1" = "-h" -o "$1" = "--help" ] && { Usage; exit 0; } + +env="$1" +shift +tox_d="${0%/*}/../.tox" +activate="$tox_d/$env/bin/activate" + + +[ -d "$tox_d" ] || fail "$tox_d: not a dir. maybe run 'tox'?" + +[ "$env" = "-l" -o "$env" = "--list" ] && { list_toxes ; exit ; } + +if [ ! -f "$activate" ]; then + error "$env: not a valid tox environment?" + error "try one of:" + list_toxes "$tox_d" " " + fail +fi +. "$activate" + +[ "$#" -gt 0 ] || set -- ${SHELL:-/bin/bash} +debian_chroot="tox:$env" exec "$@" |
