From 501e6b7cbe027e3763a674910bf9cdb806b37595 Mon Sep 17 00:00:00 2001 From: cpilch Date: Tue, 28 Mar 2017 10:21:34 -0700 Subject: Fixes Carriage Return when testing connected dev For Windows, properly handle carriage return when calling .split() on the returned devices. Change-Id: Ia76b4240ca746b46c7bfefd424e0015126c497a0 --- adb_stress_tests/util.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/adb_stress_tests/util.py b/adb_stress_tests/util.py index 6d6b70b7..abc094c4 100644 --- a/adb_stress_tests/util.py +++ b/adb_stress_tests/util.py @@ -38,10 +38,16 @@ def get_connected_devices(): output, error = proc.communicate() connected = [] # Collect connected devices. - for emulator_entry in output.split('\n')[1:]: + # Note that since Windows includes a carriage return, we + # do it in a seperate loop. + if platform.system() is not 'Windows': + for emulator_entry in output.split('\n')[1:]: if emulator_entry != '': - connected.append(emulator_entry.split('\t')[0]) - + connected.append(emulator_entry.split('\t')[0]) + else: + for emulator_entry in output.split('\r\n')[1:]: + if emulator_entry != '': + connected.append(emulator_entry.split('\t')[0]) return connected -- cgit v1.2.3