1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-19 04:21:17 +00:00

AndroidDevice: more robust getprop parsing

Ran into a development target on which one of the values in getprop
output contained a new line. Updating getprop parsing logic to handle
such cases by switching to a regex.
This commit is contained in:
Sergei Trofimov 2017-06-28 17:05:47 +01:00
parent 1f5f9cf478
commit 11859af894

View File

@ -746,12 +746,10 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
# Internal methods: do not use outside of the class.
def _update_build_properties(self, props):
try:
def strip(somestring):
return somestring.strip().replace('[', '').replace(']', '')
for line in self.execute("getprop").splitlines():
key, value = line.split(':', 1)
key = strip(key)
value = strip(value)
regex = re.compile(r'\[([^\]]+)\]\s*:\s*\[([^\]]+)\]')
for match in regex.finditer(self.execute("getprop")):
key = match.group(1).strip()
value = match.group(2).strip()
props[key] = value
except ValueError:
self.logger.warning('Could not parse build.prop.')