diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-06-02 15:01:58 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:03:58 -0800 |
commit | 664f471baf4478b664566a13e81e847dac8a2041 (patch) | |
tree | e41b0e643c7cbec8f709aeabf47b73421ae38092 /mpm/python/usrp_mpm/periph_manager/base.py | |
parent | 11401e2564bd50bdd76c84d9baedbb797ecf3f61 (diff) | |
download | uhd-664f471baf4478b664566a13e81e847dac8a2041.tar.gz uhd-664f471baf4478b664566a13e81e847dac8a2041.tar.bz2 uhd-664f471baf4478b664566a13e81e847dac8a2041.zip |
mpm: Addition Py3k fixes, all related to string/UTF-8/ascii differences
- Also fixed some error handling in various cases
Diffstat (limited to 'mpm/python/usrp_mpm/periph_manager/base.py')
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/base.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py index ef9e4b092..89282265f 100644 --- a/mpm/python/usrp_mpm/periph_manager/base.py +++ b/mpm/python/usrp_mpm/periph_manager/base.py @@ -18,6 +18,7 @@ Mboard implementation base class """ +from __future__ import print_function import os from builtins import str from builtins import range @@ -168,7 +169,13 @@ class PeriphManagerBase(object): for key in ('pid', 'serial', 'rev'): # In C++, we can only handle dicts if all the values are of the # same type. So we must convert them all to strings here: - self.mboard_info[key] = str(self._eeprom_head.get(key, '')) + try: + self.mboard_info[key] = str( + self._eeprom_head.get(key, ''), + 'ascii' + ) + except TypeError: + self.mboard_info[key] = str(self._eeprom_head.get(key, '')) if 'pid' in self._eeprom_head and self._eeprom_head['pid'] not in self.pids: self.log.error("Found invalid PID in EEPROM: 0x{:04X}. Valid PIDs are: {}".format( self._eeprom_head['pid'], |