diff options
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/ccfg-merge-debug | 4 | ||||
| -rwxr-xr-x | tools/read-dependencies | 10 | ||||
| -rwxr-xr-x | tools/tox-venv | 42 | 
3 files changed, 52 insertions, 4 deletions
| diff --git a/tools/ccfg-merge-debug b/tools/ccfg-merge-debug index 85227da7..1f08e0cb 100755 --- a/tools/ccfg-merge-debug +++ b/tools/ccfg-merge-debug @@ -51,7 +51,7 @@ def main():      c_handlers.register(ccph)      called = [] -    for (_ctype, mod) in c_handlers.iteritems(): +    for (_ctype, mod) in c_handlers.items():          if mod in called:              continue          handlers.call_begin(mod, data, frequency) @@ -76,7 +76,7 @@ def main():      # Give callbacks opportunity to finalize      called = [] -    for (_ctype, mod) in c_handlers.iteritems(): +    for (_ctype, mod) in c_handlers.items():          if mod in called:              continue          handlers.call_end(mod, data, frequency) diff --git a/tools/read-dependencies b/tools/read-dependencies index fee3efcf..6a6f3e12 100755 --- a/tools/read-dependencies +++ b/tools/read-dependencies @@ -1,6 +1,7 @@  #!/usr/bin/env python  import os +import re  import sys  if 'CLOUD_INIT_TOP_D' in os.environ: @@ -14,10 +15,15 @@ for fname in ("setup.py", "requirements.txt"):                           "exist in cloud-init root directory." % fname)          sys.exit(1) -with open(os.path.join(topd, "requirements.txt"), "r") as fp: +if len(sys.argv) > 1: +   reqfile = sys.argv[1] +else: +   reqfile = "requirements.txt" +    +with open(os.path.join(topd, reqfile), "r") as fp:      for line in fp:          if not line.strip() or line.startswith("#"):              continue -        sys.stdout.write(line) +        sys.stdout.write(re.split("[>=.<]*", line)[0].strip() + "\n")  sys.exit(0) 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 "$@" | 
