Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.toolbox
Commits
3d4eb029
Commit
3d4eb029
authored
Oct 11, 2023
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
980fde5e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
+8
-4
slapos/promise/plugin/check_rx_saturated.py
slapos/promise/plugin/check_rx_saturated.py
+3
-1
slapos/test/promise/plugin/test_check_rx_saturated.py
slapos/test/promise/plugin/test_check_rx_saturated.py
+5
-3
No files found.
slapos/promise/plugin/check_rx_saturated.py
View file @
3d4eb029
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
):
...
...
slapos/test/promise/plugin/test_check_rx_saturated.py
View file @
3d4eb029
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment