Skip to content

Commit

Permalink
Update_cmds fixes for py3
Browse files Browse the repository at this point in the history
  • Loading branch information
taldcroft committed Sep 22, 2019
1 parent 3a35b28 commit 921746d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions kadi/update_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -110,13 +109,10 @@ def fix_nonload_cmds(nl_cmds):
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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 921746d

Please sign in to comment.