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

Side by Side Diff: mojo/devtools/common/devtoolslib/android_shell.py

Issue 1505783002: Improve the fifo open timeout error message in `android_shell.py`. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import atexit 5 import atexit
6 import hashlib 6 import hashlib
7 import logging 7 import logging
8 import os 8 import os
9 import os.path 9 import os.path
10 import random 10 import random
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 def _run(): 120 def _run():
121 def _wait_for_fifo(): 121 def _wait_for_fifo():
122 for _ in xrange(max_attempts): 122 for _ in xrange(max_attempts):
123 output = subprocess.check_output(fifo_command).strip() 123 output = subprocess.check_output(fifo_command).strip()
124 if output == fifo_path: 124 if output == fifo_path:
125 return 125 return
126 time.sleep(1) 126 time.sleep(1)
127 if on_fifo_closed: 127 if on_fifo_closed:
128 on_fifo_closed() 128 on_fifo_closed()
129 raise Exception('Unable to find fifo.') 129 raise Exception('Timed out waiting for shell the create the fifo file.')
130 _wait_for_fifo() 130 _wait_for_fifo()
131 stdout_cat = subprocess.Popen( 131 stdout_cat = subprocess.Popen(
132 self._adb_command(['shell', 'run-as', _MOJO_SHELL_PACKAGE_NAME, 132 self._adb_command(['shell', 'run-as', _MOJO_SHELL_PACKAGE_NAME,
133 'cat', fifo_path]), stdout=pipe) 133 'cat', fifo_path]), stdout=pipe)
134 atexit.register(_exit_if_needed, stdout_cat) 134 atexit.register(_exit_if_needed, stdout_cat)
135 stdout_cat.wait() 135 stdout_cat.wait()
136 if on_fifo_closed: 136 if on_fifo_closed:
137 on_fifo_closed() 137 on_fifo_closed()
138 138
139 thread = threading.Thread(target=_run, name='StdoutRedirector') 139 thread = threading.Thread(target=_run, name='StdoutRedirector')
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 Results.output = rf.read() 440 Results.output = rf.read()
441 441
442 run_thread = threading.Thread(target=do_run) 442 run_thread = threading.Thread(target=do_run)
443 run_thread.start() 443 run_thread.start()
444 run_thread.join(timeout) 444 run_thread.join(timeout)
445 445
446 if run_thread.is_alive(): 446 if run_thread.is_alive():
447 self.stop_shell() 447 self.stop_shell()
448 return None, Results.output, True 448 return None, Results.output, True
449 return None, Results.output, False 449 return None, Results.output, False
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698