Skip to content

Commit ea7a991

Browse files
cladmiaabadie
authored andcommitted
Get hostname from 'hostname' file
Will allow running from any computer even with "invalid" hostname.
1 parent 4fc7bbc commit ea7a991

File tree

5 files changed

+5
-2
lines changed

5 files changed

+5
-2
lines changed

gateway_code/board_config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
""" Board Config """
2424

25-
import os
2625
import functools
2726
import gateway_code.config as config # allow mocking as 'gateway_code.config'
2827
from gateway_code import profile
@@ -43,7 +42,7 @@ def __init__(self):
4342
self.cn_class = config.control_node_class(cn_type)
4443

4544
self.robot_type = config.read_config('robot', None)
46-
self.node_id = os.uname()[1]
45+
self.node_id = config.read_config('hostname')
4746

4847
self.profile_from_dict = functools.partial(profile.Profile.from_dict,
4948
self.board_class)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
invalid-00
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
m3-00
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
m3-00

gateway_code/tests/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def read_config_mock(board_type, **kwargs):
3434

3535
config_dict = kwargs.copy()
3636
config_dict['board_type'] = board_type
37+
config_dict.setdefault('hostname', '%s-00' % board_type)
3738

3839
def read_config(key, default=IOError):
3940
""" read_config_mock """

0 commit comments

Comments
 (0)