pyepics / newportxps

python support code for NewportXPS drivers
BSD 2-Clause "Simplified" License
21 stars 18 forks source link

"Could not read system.ini!!!" parsing issue #22

Open l-reymond opened 3 months ago

l-reymond commented 3 months ago

Hi !

I have had trouble communicating with a Newport XPS-Q8 controller, and after thorough debugging, I found a workaround that might be of use. First, I got the "Could not read system.ini!!!" error, and got thrown off by others experiencing similar symptoms.

As the content of the "system.ini" file was correctly loaded into local variables (initext), I figured it was not a (S)FTP problem, which was then confirmed by the traceback error I obtained (after commenting the try/except in NewportXPS.connect()):

Traceback (most recent call last): File "folder\test.py", line 4, in xps = NewportXPS('XXX.XXX.XXX.XXX', username='user', password='pwd') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "folder.venv\Lib\site-packages\newportxps\newportxps.py", line 65, in init self.connect() File "folder.venv\Lib\site-packages\newportxps\newportxps.py", line 123, in connect self.read_systemini() File "folder.venv\Lib\site-packages\newportxps\newportxps.py", line 173, in read_systemini sconf.readfp(StringIO(initext)) ^^^^^^^^^^^^ AttributeError: 'ConfigParser' object has no attribute 'readfp'. Did you mean: 'read'?

As it looked like a parsing error, after some digging, I eventually replaced the conflictive line sconf.readfp(StringIO(initext)) by sconf.read_string(initext) that did the job. I am unsure of the consequences of that change and the origin of the issue (maybe packages versions ?). Do you have any idea ?

The "system.ini" file: system.txt

newville commented 3 months ago

@l-reymond Thanks. I recently (like, a couple weeks ago!) saw a similar problem using Python 3.12 and changed the master branch to sconf.read_file(StringIO(initext)). But I think sconf.read_string(initext) is better, and will fix that.

I'm intending to add a more general trajectory generator, and then release a version 1.0, hoping for later this week....

newville commented 3 months ago

@l-reymond This is fixed in version 0.9.

l-reymond commented 3 months ago

@newville Thank you so much for your reactivity. And I am glad I could provide a tiny piece of the puzzle.