EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: pvaPy: PvObject - odict_keys not subscriptable issue
From: Kuldeep Joshi via Tech-talk <tech-talk at aps.anl.gov>
To: "Veseli, Sinisa" <sveseli at anl.gov>
Cc: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Wed, 6 Oct 2021 05:53:17 +0000
Hello,
Thank you the code with your suggested modification is working.

I am unable to execute ca_table_server.py located in the table folder (of Phoebus Examples)  with Python3. Can I use the pcaspy lib for python3
It works fine with python2.7

I tried another Phoebus demo code server.py at this path "Display Builder/table" located at

Here I have incorporated the dict() call as per your suggestion. Table is visible only for the first table widget.
For the remaining widgets I am seeing structure for the pva. I guess the structure is not proper.
pl find the snap attached.

Regards,
Kuldeep



On Tue, Oct 5, 2021 at 2:08 PM Veseli, Sinisa <sveseli at anl.gov> wrote:
Hi,

For python3 it looks like phoebus example needs to be modified a bit. Could you please try these changes?


bluegill2> git diff app/display/model/src/main/resources/examples/table_server/server.py
diff --git a/app/display/model/src/main/resources/examples/table_server/server.py b/app/display/model/src/main/resources/exam
index 54135d7..1e1a579 100644
--- a/app/display/model/src/main/resources/examples/table_server/server.py
+++ b/app/display/model/src/main/resources/examples/table_server/server.py
@@ -54,7 +54,7 @@ def updateValue(pv):
 
 # create PVs
 tableStructDict = {'labels' : [STRING],
-                    'value' : OrderedDict([('id', [UINT]), ('name', [STRING]), ('title', [STRING])])}
+                    'value' : dict(OrderedDict([('id', [UINT]), ('name', [STRING]), ('title', [STRING])]))}
 tablePV = PvObject(tableStructDict, "epics:nt/NTTable:1.0")
 tablePV['labels'] = ['ID', 'Name', 'Title']
 namePV = PvString('')
@@ -63,5 +63,8 @@ namePV = PvString('')
 server = PvaServer('table', tablePV)
 server.addRecord('name', namePV, updateValue)
 
-raw_input("\nEnter anything to quit\n")
+try:
+    raw_input("\nEnter anything to quit\n")
+except NameError as ex:
+    input("\nEnter anything to quit\n")

The above should work on both python2 and python3.

Please let me know if you have any issues.

Thanks,

Sinisa


--
Siniša Veseli
Scientific Software Engineering & Data Management
Advanced Photon Source
Argonne National Laboratory
(630)252-9182

From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Kuldeep Joshi via Tech-talk <tech-talk at aps.anl.gov>
Sent: Tuesday, October 5, 2021 1:54 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: pvaPy: PvObject - odict_keys not subscriptable issue
 
Hello,
I was trying to execute a python script that is available with the phoebus example.
I am getting an "odict_keys object is not subscriptable" error.
I understand this is so for all python3.x versions. The code is getting executed on Python2.x versions
However I see that pvaPy supports python3.x. What am I doing wrong.

Regards,
Kuldeep


The console output:

phoebus/example/Display Builder/table_server$ python server.py
server.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if name is '':
Traceback (most recent call last):
  File "server.py", line 58, in <module>
    tablePV = PvObject(tableStructDict, "epics:nt/NTTable:1.0")
TypeError: 'odict_keys' object is not subscriptable

Attachment: Screenshot from 2021-10-06 10-57-12.png
Description: PNG image


Replies:
Re: pvaPy: PvObject - odict_keys not subscriptable issue Veseli, Sinisa via Tech-talk
References:
pvaPy: PvObject - odict_keys not subscriptable issue Kuldeep Joshi via Tech-talk
Re: pvaPy: PvObject - odict_keys not subscriptable issue Veseli, Sinisa via Tech-talk

Navigate by Date:
Prev: RE: Backing up the ArchiverStores STS MTS LTS Epic Archiver Appliance Manoussakis, Adamandios via Tech-talk
Next: iocStats module on RTEMS-5 Ben Franksen via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
Navigate by Thread:
Prev: Re: pvaPy: PvObject - odict_keys not subscriptable issue Veseli, Sinisa via Tech-talk
Next: Re: pvaPy: PvObject - odict_keys not subscriptable issue Veseli, Sinisa via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
ANJ, 06 Oct 2021 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·