[PATCH] tbot_contrib/utils.py: collect some usefull linux utils
Heiko Schocher
hs at denx.de
Mon Apr 20 15:03:25 CEST 2020
collect usefull linux utils functions. Start with
check_systemd_services_running(lnx: linux.LinuxShell, services: list)
check if all systemd services in list services run on linux
machine lnx. If not, try to start them.
Signed-off-by: Heiko Schocher <hs at denx.de>
---
tbot_contrib/utils.py | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 tbot_contrib/utils.py
diff --git a/tbot_contrib/utils.py b/tbot_contrib/utils.py
new file mode 100644
index 0000000..8073f89
--- /dev/null
+++ b/tbot_contrib/utils.py
@@ -0,0 +1,31 @@
+# tbot, Embedded Automation Tool
+# Copyright (C) 2020 Harald Seiler
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+from tbot.machine import linux
+
+
+def check_systemd_services_running(lnx: linux.LinuxShell, services: list) -> None:
+ """
+ check if all systemd services in list services run on linux machine lnx.
+ If not, try to start them.
+
+ :param lnx: linux shell
+ :param services: list of systemd services
+ """
+ for s in services:
+ ret = lnx.exec("systemctl", "status", s, "--no-pager")
+ if ret[0] != 0:
+ lnx.test("sudo", "systemctl", "start", s)
--
2.24.1
More information about the tbot
mailing list