def showInfo(self, file=sys.stdout):  # pylint: disable=W0613
        """Show human readable summary about this object"""
        owner = f"Owner: {self.getLongName()} ({self.getShortName()})"
        myinfo = ''
        if self.myInfo:
            myinfo = f"\nMy info: {stripnl(MessageToJson(self.myInfo))}"
        mesh = "\nNodes in mesh:"
        nodes = ""
        if self.nodes:
            for n in self.nodes.values():
                # when the TBeam is first booted, it sometimes shows the raw data
                # so, we will just remove any raw keys
                keys_to_remove = ('raw', 'decoded', 'payload')
                n2 = remove_keys_from_dict(keys_to_remove, n)

                # if we have 'macaddr', re-format it
                if 'macaddr' in n2['user']:
                    val = n2['user']['macaddr']
                    # decode the base64 value
                    addr = convert_mac_addr(val)
                    n2['user']['macaddr'] = addr

                nodes = nodes + f"  {stripnl(n2)}"
        infos = owner + myinfo + mesh + nodes
        print(infos)
        return infos
Example #2
0
def test_remove_keys_from_dict_nested():
    """Test remove_keys_from_dict()"""
    keys = ('b')
    adict = {'a': {'b': 1}, 'b': 2, 'c': 3}
    exp = {'a': {}, 'c': 3}
    assert remove_keys_from_dict(keys, adict) == exp
Example #3
0
def test_remove_keys_from_dict_multiple_keys():
    """Test remove_keys_from_dict()"""
    keys = ('a', 'b')
    adict = {'a': 1, 'b': 2, 'c': 3}
    assert remove_keys_from_dict(keys, adict) == {'c': 3}
Example #4
0
def test_remove_keys_from_dict():
    """Test remove_keys_from_dict()"""
    assert remove_keys_from_dict(('b'), {'a': 1, 'b': 2}) == {'a': 1}
Example #5
0
def test_remove_keys_from_dict_empty_keys():
    """Test when keys is empty"""
    assert remove_keys_from_dict((), {'a': 1}) == {'a': 1}
Example #6
0
def test_remove_keys_from_dict_empty_dict():
    """Test when dict is empty"""
    assert not remove_keys_from_dict(('a'), {})
Example #7
0
def test_remove_keys_from_dict_empty_keys_empty_dict():
    """Test when keys and dict both are empty"""
    assert not remove_keys_from_dict((), {})