Skip to content

Commit

Permalink
Merge pull request #22 from percival-detector/dev
Browse files Browse the repository at this point in the history
Unicode updates for python 2.7
  • Loading branch information
ajgdls committed Aug 24, 2017
2 parents 293d0cd + f97b795 commit 1a6f4d2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion percival/carrier/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def load_ini(self, settings_ini):
self.log.info(map)
# First replace any true or false with 1 or 0
for item in map:
if isinstance(map[item], str):
if isinstance(map[item], str) or isinstance(map[item], unicode):
if 'false' in map[item].lower():
map[item] = 0
elif 'true' in map[item].lower():
Expand Down
16 changes: 8 additions & 8 deletions percival/carrier/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ def __init__(self, ini_file):
self._ini_filename = find_file(ini_file)
except:
# If we catch any kind of exception here then treat the parameter as the configuration
self._ini_buffer = StringIO(ini_file)
self._ini_buffer = StringIO(unicode(ini_file))

def load_ini(self):
"""
Expand Down Expand Up @@ -669,7 +669,7 @@ def __init__(self, ini_file):
self._ini_filename = find_file(ini_file)
except:
# If we catch any kind of exception here then treat the parameter as the configuration
self._ini_buffer = StringIO(ini_file)
self._ini_buffer = StringIO(unicode(ini_file))

def load_ini(self):
"""
Expand Down Expand Up @@ -727,7 +727,7 @@ def __init__(self, ini_file):
self._ini_filename = find_file(ini_file)
except:
# If we catch any kind of exception here then treat the parameter as the configuration
self._ini_buffer = StringIO(ini_file)
self._ini_buffer = StringIO(unicode(ini_file))

def load_ini(self):
"""
Expand Down Expand Up @@ -770,7 +770,7 @@ def __init__(self, ini_file):
self._ini_filename = find_file(ini_file)
except:
# If we catch any kind of exception here then treat the parameter as the configuration
self._ini_buffer = StringIO(ini_file)
self._ini_buffer = StringIO(unicode(ini_file))

def load_ini(self):
"""
Expand Down Expand Up @@ -813,7 +813,7 @@ def __init__(self, ini_file):
self._ini_filename = find_file(ini_file)
except:
# If we catch any kind of exception here then treat the parameter as the configuration
self._ini_buffer = StringIO(ini_file)
self._ini_buffer = StringIO(unicode(ini_file))

def load_ini(self):
"""
Expand Down Expand Up @@ -856,7 +856,7 @@ def __init__(self, ini_file):
self._ini_filename = find_file(ini_file)
except:
# If we catch any kind of exception here then treat the parameter as the configuration
self._ini_buffer = StringIO(ini_file)
self._ini_buffer = StringIO(unicode(ini_file))

def load_ini(self):
"""
Expand Down Expand Up @@ -907,7 +907,7 @@ def __init__(self, ini_file):
self._ini_filename = find_file(ini_file)
except:
# If we catch any kind of exception here then treat the parameter as the configuration
self._ini_buffer = StringIO(ini_file)
self._ini_buffer = StringIO(unicode(ini_file))

def load_ini(self):
"""
Expand Down Expand Up @@ -970,7 +970,7 @@ def __init__(self, ini_file):
self._ini_filename = find_file(ini_file)
except:
# If we catch any kind of exception here then treat the parameter as the configuration
self._ini_buffer = StringIO(ini_file)
self._ini_buffer = StringIO(unicode(ini_file))

def load_ini(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions percival/carrier/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def load_ini(self, settings_ini):
self._log.info("Full description of ini %s", map)
# First replace any true or false with 1 or 0
for item in map:
if isinstance(map[item], str):
if isinstance(map[item], str) or isinstance(map[item], unicode):
if 'false' in map[item].lower():
map[item] = 0
elif 'true' in map[item].lower():
Expand Down Expand Up @@ -195,7 +195,7 @@ def load_ini(self, settings_ini):
self._log.info("Full description of ini %s", map)
# First replace any true or false with 1 or 0
for item in map:
if isinstance(map[item], str):
if isinstance(map[item], str) or isinstance(map[item], unicode):
if 'false' in map[item].lower():
map[item] = 0
elif 'true' in map[item].lower():
Expand Down
5 changes: 4 additions & 1 deletion percival/detector/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from datetime import datetime, timedelta
import getpass
import sys
import traceback
is_py2 = sys.version[0] == '2'
if is_py2:
import Queue as queue
Expand Down Expand Up @@ -817,7 +818,9 @@ def command_loop(self):
except PercivalDetectorError as e:
self._active_command.complete(success=False, message=str(e))
except Exception as e:
self._active_command.complete(success=False, message="Unhandled exception: {}".format(str(e)))
type_, value_, traceback_ = sys.exc_info()
ex = traceback.format_exception(type_, value_, traceback_)
self._active_command.complete(success=False, message="Unhandled exception: {} => {}".format(str(e), str(ex)))

def execute_command(self, command):
"""
Expand Down

0 comments on commit 1a6f4d2

Please sign in to comment.