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

Side by Side Diff: mojo/devtools/common/pylib/linux_shell.py

Issue 1128153002: Rename the devtools library: pylib -> devtoolslib. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address offline comments/ devtools_lib -> devtoolslib. Created 5 years, 7 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
« no previous file with comments | « mojo/devtools/common/pylib/http_server.py ('k') | mojo/devtools/common/pylib/shell.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 subprocess
6
7 from pylib.shell import Shell
8
9
10 class LinuxShell(Shell):
11 """Wrapper around Mojo shell running on Linux.
12
13 Args:
14 executable_path: path to the shell binary
15 command_prefix: optional list of arguments to prepend to the shell command,
16 allowing e.g. to run the shell under debugger.
17 """
18
19 def __init__(self, executable_path, command_prefix=None):
20 self.executable_path = executable_path
21 self.command_prefix = command_prefix if command_prefix else []
22
23 def Run(self, arguments):
24 """Runs the shell with given arguments until shell exits, passing the stdout
25 mingled with stderr produced by the shell onto the stdout.
26
27 Returns:
28 Exit code retured by the shell or None if the exit code cannot be
29 retrieved.
30 """
31 command = self.command_prefix + [self.executable_path] + arguments
32 return subprocess.call(command, stderr=subprocess.STDOUT)
33
34 def RunAndGetOutput(self, arguments):
35 """Runs the shell with given arguments until shell exits.
36
37 Args:
38 arguments: list of arguments for the shell
39
40 Returns:
41 A tuple of (return_code, output). |return_code| is the exit code returned
42 by the shell or None if the exit code cannot be retrieved. |output| is the
43 stdout mingled with the stderr produced by the shell.
44 """
45 command = self.command_prefix + [self.executable_path] + arguments
46 p = subprocess.Popen(command, stdout=subprocess.PIPE,
47 stderr=subprocess.STDOUT)
48 (output, _) = p.communicate()
49 return p.returncode, output
OLDNEW
« no previous file with comments | « mojo/devtools/common/pylib/http_server.py ('k') | mojo/devtools/common/pylib/shell.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698