Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump pyyaml from 3.11 to 5.1 in /hbp_nrp_backend #1

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hbp_nrp_backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# other requirements
lxml==3.4.0
PyYAML==3.11
PyYAML==5.1
rospkg==1.0.38
catkin_pkg==0.2.10
pyxb==1.2.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def __load_tfs(self):
continue

try:
tfm.set_transfer_function(tf.code, new_code, tf.name, tf.active)
tfm.set_transfer_function(tf.code, new_code, tf.name, tf.active, tf.priority)
except tfm.TFLoadingException as loading_e:
logger.error(loading_e)
tfm.set_flawed_transfer_function(tf.code, tf.name, loading_e)
Expand Down
12 changes: 10 additions & 2 deletions hbp_nrp_commons/hbp_nrp_commons/sim_config/SimConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,25 @@ class _TF(object): # pragma: no cover
"""
Model to store TF information
"""
def __init__(self, name, code, src=None, active=False):
def __init__(self, name, code, src=None, active=False, priority=0):
"""
Initialize a transfer function object

:param name: name of the transfer function
:param code: compiled (restricted) source code of transfer function
:param src: source code (plain text) of transfer function
:param active: active state of the transfer function
:param priority: specifies execution order of the transfer function. Transfer functions with
higher priority are executed first.
"""
self.name = name
self.code = code
self.src = src
self.active = active
try:
self.priority = int(priority)
except (ValueError, TypeError):
self.priority = 0


class SimConfig(object):
Expand Down Expand Up @@ -331,8 +338,9 @@ def _read_dom_data(self):
code = generate_tf(_tf, self.sim_dir)
name = get_tf_name(code)
src = _tf.src if _tf.src else None # must be not None and not ""
priority = _tf.priority if _tf.priority else 0
active = bool(_tf.active) if _tf.active else False
self._tfs.append(_TF(name, code, src, active))
self._tfs.append(_TF(name, code, src, active, priority))

def _read_robot_models(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from mock import patch, Mock, MagicMock, ANY, mock_open
from hbp_nrp_commons.MockUtil import MockUtil

from hbp_nrp_commons.sim_config.SimConfig import SimConfig
from hbp_nrp_commons.sim_config.SimConfig import SimConfig, _TF

__author__ = 'Hossain Mahmud'

Expand Down Expand Up @@ -116,6 +116,19 @@ def test_read_data(self):
def test_properties(self):
pass

def test_priority_is_int(self):
# test _TF priority value is always initialized to an integer
tf_1 = _TF("dummy_name", "dummy_code",priority=None)
tf_2 = _TF("dummy_name", "dummy_code", priority="string_value")
tf_3 = _TF("dummy_name", "dummy_code", priority=False)
tf_4 = _TF("dummy_name", "dummy_code", priority=3.1416)

self.assertTrue(type(tf_1.priority) == int)
self.assertTrue(type(tf_2.priority) == int)
self.assertTrue(type(tf_3.priority) == int)
self.assertTrue(type(tf_4.priority) == int)



if __name__ == '__main__':
unittest.main()