labscript-suite-temp-2 / blacs

BLACS, part of the labscript suite, provides an interface to hardware used to control a buffered experiment. It manages a queue of shots to be run as well as providing manual control over devices between shots.
Other
0 stars 0 forks source link

BLACS plugin initialization not Python 2 compatible #35

Closed philipstarkey closed 6 years ago

philipstarkey commented 6 years ago

Original report (archived issue) by David Meyer (Bitbucket: dihm, GitHub: dihm).


I'm getting an error starting BLACS after merging in up to 828 with my old Py2/Qt4 setup:

#!python

Traceback (most recent call last):
  File "C:\labscript_suite\blacs\__main__.py", line 148, in <module>
    import plugins
  File "C:\labscript_suite\blacs\plugins\__init__.py", line 34, in <module>
    if not module_name in exp_config['BLACS/plugins']:
AttributeError: LabConfig instance has no attribute '__getitem__'

It looks like some Python3 configparser syntax worked its way in on line 34 of plugins/__init__.py

philipstarkey commented 6 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


Ah, we are all on Python 2 since BLACS hasn't been ported yet, but this is caused by the fact that the configparser module from Python 3 has been backported to Python 2 and is available as a separate package, which clearly some of us have installed.

labconfig does the following in order to work in both Python 2 and Python 3:

#!python

try:
    import configparser
except ImportError:
    # Python 2
    import ConfigParser as configparser

But the configparser module exists for those of us in Python 2 who have the backported module.

Rather than require the backported module I'll just fix the syntax to be ConfigParser compatible.

philipstarkey commented 6 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


Fixed by pull request #27