Skip to content

Commit 2850476

Browse files
authored
Merge pull request #4 from Bastian-Krause/bst/barebox
barebox: add devinfo helper
2 parents 7ddf293 + d9d5161 commit 2850476

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

labgridhelper/barebox.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,31 @@ def get_globals(command):
2727
assert isinstance(command, BareboxDriver)
2828
out = command.run_check("global")
2929
return split_to_dict(out, delimiter=":", strip_chars="* ")
30+
31+
def devinfo(command, device):
32+
"""Returns the devinfo as dict
33+
Args:
34+
command (BareboxDriver): An instance of the BareboxDriver
35+
device (string): device to call devinfo on
36+
Returns:
37+
dict: parameters
38+
"""
39+
assert isinstance(command, BareboxDriver)
40+
stdout = command.run_check("devinfo {}".format(device))
41+
42+
results = {}
43+
state = '\n'.join(stdout)
44+
for line in state.splitlines():
45+
line = line.strip()
46+
if not line:
47+
continue
48+
k, v = line.split(':', 1)
49+
v = v.strip()
50+
if ' ' in v:
51+
v, _ = v.split(' ', 1)
52+
if not k or not v:
53+
continue
54+
v = v.strip()
55+
results[k] = v
56+
57+
return results

0 commit comments

Comments
 (0)