mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-04-14 06:40:52 +01: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:
parent
1f5f9cf478
commit
11859af894
@ -746,12 +746,10 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
|
|||||||
# Internal methods: do not use outside of the class.
|
# Internal methods: do not use outside of the class.
|
||||||
def _update_build_properties(self, props):
|
def _update_build_properties(self, props):
|
||||||
try:
|
try:
|
||||||
def strip(somestring):
|
regex = re.compile(r'\[([^\]]+)\]\s*:\s*\[([^\]]+)\]')
|
||||||
return somestring.strip().replace('[', '').replace(']', '')
|
for match in regex.finditer(self.execute("getprop")):
|
||||||
for line in self.execute("getprop").splitlines():
|
key = match.group(1).strip()
|
||||||
key, value = line.split(':', 1)
|
value = match.group(2).strip()
|
||||||
key = strip(key)
|
|
||||||
value = strip(value)
|
|
||||||
props[key] = value
|
props[key] = value
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.logger.warning('Could not parse build.prop.')
|
self.logger.warning('Could not parse build.prop.')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user