Skip to content

Instantly share code, notes, and snippets.

@reszelaz
Created July 29, 2019 09:47
Show Gist options
  • Save reszelaz/de7cd7e80e07edd0df854462866e10d2 to your computer and use it in GitHub Desktop.
Save reszelaz/de7cd7e80e07edd0df854462866e10d2 to your computer and use it in GitHub Desktop.
Exception raised when opening showscan in Sardana spock with Python 3 and PyMCA 5.1.3 (default version on Debian 9). Fixed in PyMca 5.5.
```
Door_demo2_1 [25]: showscan
Trying to open local scan file /tmp/demo1.h5...
AttributeError: 'str' object has no attribute 'decode'
(For more detailed information type: python_error)
Door_demo2_1 [26]: python_error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-25-47bb900506ec> in <module>()
----> 1 get_ipython().magic('showscan ')
/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py in magic(self, arg_s)
2156 magic_name, _, magic_arg_s = arg_s.partition(' ')
2157 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2158 return self.run_line_magic(magic_name, magic_arg_s)
2159
2160 #-------------------------------------------------------------------------
/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line)
2077 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2078 with self.builtin_trap:
-> 2079 result = fn(*args,**kwargs)
2080 return result
2081
<decorator-gen-129> in showscan(self, parameter_s)
/usr/lib/python3/dist-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
186 # but it's overkill for just that one bit of state.
187 def magic_deco(arg):
--> 188 call = lambda f, *a, **k: f(*a, **k)
189
190 if callable(arg):
/usr/local/lib/python3.5/dist-packages/sardana/spock/magic.py in showscan(self, parameter_s)
127 else:
128 scan_nb = int(params[0])
--> 129 door.show_scan(scan_nb, online=online)
130
131
/usr/local/lib/python3.5/dist-packages/sardana/spock/spockms.py in show_scan(self, scan_nb, online)
435 self._plotter.show_scan(scan_nb=scan_nb,
436 scan_history_info=scan_history_info,
--> 437 directory_map=directory_map)
438
439 def stateChanged(self, s, t, v):
/usr/local/lib/python3.5/dist-packages/sardana/spock/spockms.py in show_scan(self, scan_nb, scan_history_info, directory_map)
171
172 print("Trying to open local scan file %s..." % (local_file,))
--> 173 taurus_nexus_widget.openFile(local_file)
174 taurus_nexus_widget.show()
175 nexus_widget = taurus_nexus_widget.neXusWidget()
/usr/local/lib/python3.5/dist-packages/taurus/qt/qtgui/extra_nexus/taurusnexuswidget.py in openFile(self, fname)
120 fname, _ = compat.getOpenFileName(self, 'Choose NeXus File', '')
121 if fname:
--> 122 self.__nexusFile = self.__fileModel.openFile(fname)
123
124 def onHDF5WidgetSignal(self, ddict):
/usr/lib/python3/dist-packages/PyMca5/PyMcaGui/io/hdf5/HDF5Widget.py in openFile(self, filename, weakreference)
482 self.rootItem.appendChild(refProxy)
483 else:
--> 484 self.rootItem.appendChild(phynxFile)
485 ddict = {}
486 ddict['event'] = "fileAppended"
/usr/lib/python3/dist-packages/PyMca5/PyMcaGui/io/hdf5/HDF5Widget.py in appendChild(self, item)
165
166 def appendChild(self, item):
--> 167 self.children.append(H5FileProxy(item, self))
168 self._identifiers.append(id(item))
169
/usr/lib/python3/dist-packages/PyMca5/PyMcaGui/io/hdf5/HDF5Widget.py in __init__(self, ffile, parent)
332
333 def __init__(self, ffile, parent=None):
--> 334 super(H5FileProxy, self).__init__(ffile, ffile, parent)
335 self._name = ffile.name
336 self._filename = self.file.name
/usr/lib/python3/dist-packages/PyMca5/PyMcaGui/io/hdf5/HDF5Widget.py in __init__(self, ffile, node, parent, path)
291 _type = "%s" % node.attrs[cname]
292 else:
--> 293 _type = node.attrs[cname].decode('utf=8')
294 self._type = _type
295 break
AttributeError: 'str' object has no attribute 'decode'
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment