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 <2021> 2022 2023 2024 2025 | 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 <2021> 2022 2023 2024 2025 |
<== 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 |
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.pydiff --git a/app/display/model/src/main/resources/examples/table_server/server.py b/app/display/model/src/main/resources/examindex 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 PVstableStructDict = {'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 issueHello,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