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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import os
6 import subprocess
7 import threading
ghost stip (do not use) 2015/10/15 20:02:54 remove unused import
8
9 from infra.tools.cros_pin.logger import LOGGER
10
11
12 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
13 LOGGER.info("Executing command %s (cwd=%s)", cmd, (cwd or os.getcwd()))
14 if dry_run:
15 LOGGER.info('Dry Run: Not actually executing.')
16 return (0, "")
17 proc = subprocess.Popen(
18 cmd,
19 stdout=subprocess.PIPE,
20 stderr=subprocess.STDOUT,
21 cwd=cwd)
22
23 output = []
24 for line in iter(proc.stdout.readline, b''):
25 LOGGER.debug('[%s]: %s', cmd[0], line.rstrip())
26 output.append(line)
27
28 proc.wait()
29 return proc.returncode, ''.join(output)
30
31
32 def check_call(cmd, **kwargs):
33 rv, stdout = call(cmd, **kwargs)
34 if rv != 0:
35 raise subprocess.CalledProcessError(rv, cmd, None)
36 return stdout
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698