From a51f3eb1e911051bab5915d4014f3e043a5ebf4b Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Sun, 8 Sep 2019 08:48:34 -0400 Subject: [PATCH] Update_cmds fixes for py3 --- kadi/update_cmds.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/kadi/update_cmds.py b/kadi/update_cmds.py index 102637e8..6de50419 100644 --- a/kadi/update_cmds.py +++ b/kadi/update_cmds.py @@ -2,11 +2,10 @@ import os import argparse import difflib +import pickle import numpy as np import tables -from six.moves import cPickle as pickle -import six import pyyaks.logger import Ska.DBI @@ -105,18 +104,15 @@ def fix_nonload_cmds(nl_cmds): if cmd['msid'] is not None: new_cmd['params']['msid'] = str(cmd['msid']) - # De-unicode and de-numpy (otherwise unpickling on PY3 has problems). + # De-numpy (otherwise unpickling on PY3 has problems). if 'params' in cmd: params = new_cmd['params'] for key, val in cmd['params'].items(): key = str(key) - if isinstance(val, six.string_types): - val = str(val) - else: - try: - val = val.item() - except Exception: - pass + try: + val = val.item() + except AttributeError: + pass params[key] = val new_cmds.append(new_cmd) @@ -316,7 +312,10 @@ def add_h5_cmds(h5file, idx_cmds): # Define the column names that specify a complete and unique row key_names = ('date', 'type', 'tlmsid', 'scs', 'step', 'timeline_id', 'vcdu') - h5d_recent_vals = [tuple(str(row[x]) for x in key_names) for row in h5d_recent] + h5d_recent_vals = [tuple( + row[x].decode('ascii') if isinstance(row[x], bytes) else str(row[x]) + for x in key_names) + for row in h5d_recent] idx_cmds_vals = [tuple(str(x) for x in row[1:]) for row in idx_cmds] diff = difflib.SequenceMatcher(a=h5d_recent_vals, b=idx_cmds_vals, autojunk=False)