From e03b35259869e969c3c41bfd49d52dde1f06f129 Mon Sep 17 00:00:00 2001
From: Erik Kooistra <kooistra@astron.nl>
Date: Tue, 21 Nov 2017 10:47:15 +0000
Subject: [PATCH] Utility to run a command in parallel on multiple LCUs.

---
 .../commissioning/run_command_on_lcus.py      | 63 +++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 applications/apertif/commissioning/run_command_on_lcus.py

diff --git a/applications/apertif/commissioning/run_command_on_lcus.py b/applications/apertif/commissioning/run_command_on_lcus.py
new file mode 100644
index 0000000000..be2927c527
--- /dev/null
+++ b/applications/apertif/commissioning/run_command_on_lcus.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+###############################################################################
+#
+# Copyright (C) 2017
+# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
+# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+# Author:
+# . Daniel van der Schuur
+# . Eric Kooistra
+# Purpose:
+# . Run same UniBoard command on remote dish LCUs in parallel
+# Usage: 
+# . python run_command_on_lcus.py --tel <telescopes 2,3,4,..,c,d> -s <'command string, in quotes if it has spaces'>
+#
+#   For example to read current time on different LCUs, all LCUs should report nearly the same time:
+#
+#   python run_command_on_lcus.py --tel 2,5,6,8,9,c,d -s 'python $UPE/base/print_time.py'
+import sys
+import os
+import time
+import shell
+import common as cm
+import test_case
+
+tc = test_case.Testcase('RUN_ON_LCUs - ', '')
+
+lcu_str = 'Targetting LCUs: '
+LCUS = []
+for tel in tc.telStrList:
+    if tel == '':
+        continue
+    LCUS.append('lcu-rt' + str(tel))
+    lcu_str = lcu_str + ' lcu-rt' + str(tel) + ','
+tc.append_log(0, lcu_str[:-1])
+
+#tc.append_log(0, 'Wait for PPS')
+#cmd_str = 'python $UPE/peripherals/util_ppsh.py --unb 0 --bn 0 -n 4'
+#print 'cmd_str = %s' % cmd_str
+#shell.ssh_cmd(LCUS[0], cmd_str, tc)
+
+tc.append_log(0, 'Issue parallel command')
+cmd_str = tc.gpString
+for lcu in LCUS:
+    lcu_cmd = ['/usr/bin/ssh', 'ssh', lcu, cmd_str]
+    print lcu_cmd
+    os.spawnl(os.P_NOWAIT, *lcu_cmd)
+
-- 
GitLab