File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 11from labgrid .protocol import CommandProtocol
2+ import re
3+
4+ def get_systemd_version (command ):
5+ """Returns systemd version retrieved by parsing output of `systemd --version`
6+
7+ Args:
8+ command (CommandProtocol): An instance of a Driver implementing the CommandProtocol
9+
10+ Returns:
11+ int: systemd version number
12+ """
13+ assert isinstance (command , CommandProtocol ), "command must be a CommandProtocol"
14+
15+ out = command .run_check ("systemctl --version" )
16+ out = out [0 ]
17+
18+ parsed = re .search (r'^systemd\s+(?P<version>\d+)\s+' , out )
19+ if not parsed :
20+ raise ValueError ("Systemd version output changed" )
21+ return int (parsed .group ("version" ))
222
323def get_systemd_status (command ):
424 assert isinstance (command , CommandProtocol ), "command must be a CommandProtocol"
You can’t perform that action at this time.
0 commit comments