| Index: scripts/slave/recipe_modules/cipd/resources/ensure.py
|
| diff --git a/scripts/slave/recipe_modules/cipd/resources/ensure.py b/scripts/slave/recipe_modules/cipd/resources/ensure.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5881086526992417a21788392f3cbc73b884e0fa
|
| --- /dev/null
|
| +++ b/scripts/slave/recipe_modules/cipd/resources/ensure.py
|
| @@ -0,0 +1,47 @@
|
| +import json
|
| +import os
|
| +import subprocess
|
| +import sys
|
| +
|
| +def execute(cmd):
|
| + """Runs a subprocess redirecting its stdout and stderr to the log.
|
| +
|
| + Args:
|
| + cmd: list with command line arguments.
|
| +
|
| + Returns:
|
| + Process exit code.
|
| + """
|
| + print('Running ' + ' '.join(cmd))
|
| + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
| + line = ''
|
| + while True:
|
| + buf = proc.stdout.read(1)
|
| + if not buf:
|
| + if line:
|
| + print(line.strip())
|
| + break
|
| + if buf == '\n':
|
| + print(line.strip())
|
| + line = ''
|
| + else:
|
| + line += buf
|
| + code = proc.wait()
|
| + if code:
|
| + print('Failed with exit code: %d', code)
|
| + return code
|
| +
|
| +
|
| +def main():
|
| + data = json.load(sys.stdin)
|
| + pkg_list = data['list']
|
| + root = data['root']
|
| +
|
| + exit_code = 0
|
| + # return if this client version is already installed.
|
| +
|
| + exit_code = execute(["./cipd", "ensure", "--root=%s" % root, "--list=%s" % pkg_list])
|
| + return exit_code
|
| +
|
| +if __name__ == '__main__':
|
| + sys.exit(main())
|
|
|