Commit 3d4eb029 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 980fde5e
from .util import get_json_log_data_interval from .util import get_json_log_data_interval
from .util import JSONPromise from .util import JSONPromise
import json
from zope.interface import implementer from zope.interface import implementer
from slapos.grid.promise import interface from slapos.grid.promise import interface
...@@ -13,6 +14,7 @@ class RunPromise(JSONPromise): ...@@ -13,6 +14,7 @@ class RunPromise(JSONPromise):
self.testing = self.getConfig('testing') == "True" self.testing = self.getConfig('testing') == "True"
self.amarisoft_stats_log = self.getConfig('amarisoft-stats-log') self.amarisoft_stats_log = self.getConfig('amarisoft-stats-log')
self.stats_period = int(self.getConfig('stats-period')) self.stats_period = int(self.getConfig('stats-period'))
self.rx_chan_list = json.loads(self.getConfig('rf-rx-chan-list'))
self.max_rx_sample_db = float(self.getConfig('max-rx-sample-db')) self.max_rx_sample_db = float(self.getConfig('max-rx-sample-db'))
def sense(self): def sense(self):
...@@ -23,7 +25,7 @@ class RunPromise(JSONPromise): ...@@ -23,7 +25,7 @@ class RunPromise(JSONPromise):
saturated = False saturated = False
for rx_antenna_list in map(lambda x: x['samples']['rx'], data_list): for rx_antenna_list in map(lambda x: x['samples']['rx'], data_list):
rx_list = map(lambda x: float(x['max']), rx_antenna_list) rx_list = map(lambda x: float(x['max']), [rx_antenna_list[i] for i in self.rx_chan_list])
if not max_rx_list: if not max_rx_list:
max_rx_list = list(rx_list) max_rx_list = list(rx_list)
for i, rx in enumerate(rx_list): for i, rx in enumerate(rx_list):
......
...@@ -44,9 +44,9 @@ class TestCheckRXSaturated(TestPromisePluginMixin): ...@@ -44,9 +44,9 @@ class TestCheckRXSaturated(TestPromisePluginMixin):
f.write("""{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {"samples": {"rx": [{"max": %f}, {"max": %f}]}}} f.write("""{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {"samples": {"rx": [{"max": %f}, {"max": %f}]}}}
{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {"samples": {"rx": [{"max": %f}, {"max": %f}]}}} {"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {"samples": {"rx": [{"max": %f}, {"max": %f}]}}}
{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {"samples": {"rx": [{"max": %f}, {"max": %f}]}}}""" % ( {"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {"samples": {"rx": [{"max": %f}, {"max": %f}]}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], -5.0, -6.0, (datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], +99, -6.0,
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], -2.0, -3.0, (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], +99, -3.0,
(datetime.now() - timedelta(seconds=5)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], -9.0, -7.0, (datetime.now() - timedelta(seconds=5)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], +99, -7.0,
)) ))
def writePromise(self, **kw): def writePromise(self, **kw):
...@@ -59,6 +59,7 @@ class TestCheckRXSaturated(TestPromisePluginMixin): ...@@ -59,6 +59,7 @@ class TestCheckRXSaturated(TestPromisePluginMixin):
'amarisoft-stats-log': self.amarisoft_stats_log, 'amarisoft-stats-log': self.amarisoft_stats_log,
'stats-period': 10, 'stats-period': 10,
'max-rx-sample-db': 0.0, 'max-rx-sample-db': 0.0,
'rf-rx-chan-list': '[1]',
}) })
self.configureLauncher() self.configureLauncher()
self.launcher.run() self.launcher.run()
...@@ -68,6 +69,7 @@ class TestCheckRXSaturated(TestPromisePluginMixin): ...@@ -68,6 +69,7 @@ class TestCheckRXSaturated(TestPromisePluginMixin):
'amarisoft-stats-log': self.amarisoft_stats_log, 'amarisoft-stats-log': self.amarisoft_stats_log,
'stats-period': 10, 'stats-period': 10,
'max-rx-sample-db': -3.0, 'max-rx-sample-db': -3.0,
'rf-rx-chan-list': '[1]',
}) })
self.configureLauncher() self.configureLauncher()
with self.assertRaises(PromiseError): with self.assertRaises(PromiseError):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment