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: "Veseli, Sinisa via Tech-talk" <tech-talk at aps.anl.gov>
To: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>, Kuldeep Joshi <kuldeep.joshi at gmail.com>
Date: Tue, 5 Oct 2021 14:08:45 +0000
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
sveseli at anl.gov
(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

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

Navigate by Date:
Prev: Fw: Backing up the ArchiverStores STS MTS LTS Epic Archiver Appliance Wilson, Andy (DLSLtd, RAL, LSCI) via Tech-talk
Next: RE: Odd characters in temperatures showing in Phoebus Leblanc, Gregory 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: pvaPy: PvObject - odict_keys not subscriptable issue Kuldeep Joshi via Tech-talk
Next: Re: pvaPy: PvObject - odict_keys not subscriptable issue Kuldeep Joshi 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 ·