From 664f471baf4478b664566a13e81e847dac8a2041 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 2 Jun 2017 15:01:58 -0700 Subject: mpm: Addition Py3k fixes, all related to string/UTF-8/ascii differences - Also fixed some error handling in various cases --- mpm/python/usrp_mpm/periph_manager/base.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'mpm/python/usrp_mpm/periph_manager/base.py') 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'], -- cgit v1.2.3