From 109fcc6deb79606faf197b58a131e977355afec6 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Tue, 26 Sep 2017 13:30:15 +0100 Subject: [PATCH] AndroidTarget: fix ps() ps() splits the output on whiestspace into fields; always expecting nine. In some cases, wchan field may be blank, resulting in only eight chunks after the split. Detect that case and insert and empty entry at the appropriate index. --- devlib/target.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/devlib/target.py b/devlib/target.py index fca798c..4b2da42 100644 --- a/devlib/target.py +++ b/devlib/target.py @@ -1024,8 +1024,12 @@ class AndroidTarget(Target): result = [] for line in lines: parts = line.split(None, 8) - if parts: - result.append(PsEntry(*(parts[0:1] + map(int, parts[1:5]) + parts[5:]))) + if not parts: + continue + if len(parts) == 8: + # wchan was blank; insert an empty field where it should be. + parts.insert(5, '') + result.append(PsEntry(*(parts[0:1] + map(int, parts[1:5]) + parts[5:]))) if not kwargs: return result else: