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

Unified Diff: build/android/pylib/ports.py

Issue 1238293004: [Android] Fix netstat parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/ports.py
diff --git a/build/android/pylib/ports.py b/build/android/pylib/ports.py
index 578152cb0f1e029f53a06294e06b3c2fe19ca0a5..fa0345b6b96efb01d40fe58ea7f355e514e091a6 100644
--- a/build/android/pylib/ports.py
+++ b/build/android/pylib/ports.py
@@ -109,8 +109,9 @@ def IsDevicePortUsed(device, device_port, state=''):
Returns:
True if the port on device is already used, otherwise returns False.
"""
- base_url = '127.0.0.1:%d' % device_port
- netstat_results = device.RunShellCommand('netstat')
+ base_urls = ('127.0.0.1:%d' % device_port, 'localhost:%d' % device_port)
+ netstat_results = device.RunShellCommand(
+ ['netstat', '-a'], check_return=True, large_output=True)
for single_connect in netstat_results:
# Column 3 is the local address which we want to check with.
connect_results = single_connect.split()
@@ -120,7 +121,7 @@ def IsDevicePortUsed(device, device_port, state=''):
raise Exception('Unexpected format while parsing netstat line: ' +
single_connect)
is_state_match = connect_results[5] == state if state else True
- if connect_results[3] == base_url and is_state_match:
+ if connect_results[3] in base_urls and is_state_match:
return True
return False
« 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