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

Unified Diff: infra/tools/cros_pin/execute.py

Issue 1403313002: Added `cros_pin` CrOS pin-bump tool. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fixed bugs, better handling of insufficient slave pool sizes. Created 5 years, 2 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: infra/tools/cros_pin/execute.py
diff --git a/infra/tools/cros_pin/execute.py b/infra/tools/cros_pin/execute.py
new file mode 100644
index 0000000000000000000000000000000000000000..f770d248b3c5bfd03e94f008095d3f14cccb0db2
--- /dev/null
+++ b/infra/tools/cros_pin/execute.py
@@ -0,0 +1,36 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import subprocess
+import threading
ghost stip (do not use) 2015/10/15 20:02:54 remove unused import
+
+from infra.tools.cros_pin.logger import LOGGER
+
+
+def call(cmd, cwd=None, dry_run=False):
ghost stip (do not use) 2015/10/15 20:02:54 this whole function seems overkill. this is just t
dnj 2015/10/15 21:06:41 Well, execute stuff and: 1) Print output to STDERR
+ LOGGER.info("Executing command %s (cwd=%s)", cmd, (cwd or os.getcwd()))
+ if dry_run:
+ LOGGER.info('Dry Run: Not actually executing.')
+ return (0, "")
+ proc = subprocess.Popen(
+ cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ cwd=cwd)
+
+ output = []
+ for line in iter(proc.stdout.readline, b''):
+ LOGGER.debug('[%s]: %s', cmd[0], line.rstrip())
+ output.append(line)
+
+ proc.wait()
+ return proc.returncode, ''.join(output)
+
+
+def check_call(cmd, **kwargs):
+ rv, stdout = call(cmd, **kwargs)
+ if rv != 0:
+ raise subprocess.CalledProcessError(rv, cmd, None)
+ return stdout

Powered by Google App Engine
This is Rietveld 408576698