Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Unified Diff: scripts/slave/recipe_modules/cipd/resources/ensure.py

Issue 1193813004: cipd recipe_module (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: added ensure_installed Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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())

Powered by Google App Engine
This is Rietveld 408576698