Merge pull request #229 from mkinney/check_for_multiple_mac_conversions

suggested fix from MitchConner912 for not converting mac address more…
This commit is contained in:
mkinney authored and GitHub committed 2022-01-12 17:13:14 -08:00
commit 63c60d4cea
2 files changed
+6 -2

No files matched your search

+1
View File
@@ -249,4 +249,5 @@ def test_findPorts_when_none_found(patch_comports):
def test_convert_mac_addr():
"""Test convert_mac_addr()"""
assert convert_mac_addr('/c0gFyhb') == 'fd:cd:20:17:28:5b'
assert convert_mac_addr('fd:cd:20:17:28:5b') == 'fd:cd:20:17:28:5b'
assert convert_mac_addr('') == ''
+5 -2
View File
@@ -3,6 +3,7 @@
import traceback
from queue import Queue
import os
import re
import sys
import base64
import time
@@ -238,5 +239,7 @@ def convert_mac_addr(val):
val - base64 encoded value (ex: '/c0gFyhb'))
returns: a string formatted like a mac address (ex: 'fd:cd:20:17:28:5b')
"""
val_as_bytes = base64.b64decode(val)
return hexstr(val_as_bytes)
if not re.match("[0-9a-f]{2}([-:]?)[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", val):
val_as_bytes = base64.b64decode(val)
return hexstr(val_as_bytes)
return val