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

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: Added pinfile.py tests, cleanup. 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
« no previous file with comments | « infra/tools/cros_pin/cros_pin.py ('k') | infra/tools/cros_pin/logger.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ccacbefb38765ca48241c883af80301abfa1217e
--- /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
+
+from infra.tools.cros_pin.logger import LOGGER
+
+
+def call(cmd, cwd=None, dry_run=False):
+ LOGGER.info("Executing command %s (cwd=%s)", cmd, (cwd or os.getcwd()))
+ if dry_run:
+ LOGGER.info('Dry Run: Not actually executing.')
+ return (0, "")
+
+ output = []
+ proc = subprocess.Popen(
+ cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ cwd=cwd)
+
+ 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
« no previous file with comments | « infra/tools/cros_pin/cros_pin.py ('k') | infra/tools/cros_pin/logger.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698