Written by

Question Phillip Wu · Jan 16

Python (embedded) for SYS.Mirror.GetFailoverMemberStatus does not work

Hi,

I'm using embedded Python as follows:

AUMHTESTTC01:%SYS>do ##class(%SYS.Python).Shell()
Python 3.6.15 (default, Sep 232021, 15:41:43) [GCC] on linux
Type quit() or Ctrl-D to exit this shell.
>>> import iris
>>> mirror=iris.cls('SYS.Mirror')
>>> pri=[]
>>> alt=[]
>>> status=mirror.GetFailoverMemberStatus(pri,alt)
>>> print(status)
1>>> print(pri)
[]
>>> print(alt)
[]
>>> exit()

However the equivalent ObjectScript works:

%SYS>set sc=##class(SYS.Mirror).GetFailoverMemberStatus(.pri,.alt)
%SYS>zw pri
pri=$lb("SERVERA.FOO.BAR.ORG/STAGE","SERVERA.foo.bar.org|2188","Primary","Active","172.31.33.69|1972","SERVERA.foo.bar.org|1972")
%SYS>zw alt
alt=$lb("SERVERB.FOO.BAR.ORG/STAGE","SERVERB.foo.bar.org|2188","Backup","Active","172.31.33.70|1972","SERVERB.foo.bar.org|1972")

Can someone please explain how to achieve the ObjectScript code in Python?
Thanks
 

Comments

Guillaume Rongier · Jan 16
>>> import iris
>>> mirror=iris.cls('SYS.Mirror')
>>> pri_ref = iris.ref(None)
>>> alt_ref = iris.ref(None)
>>> sc=mirror.GetFailoverMemberStatus(pri_ref,alt_ref)
>>> pri_ref.value
>>> alt_ref.value

Something like this should work

0
Phillip Wu  Jan 21 to Guillaume Rongier

Thanks. That seems to have done the trick.
pri_ref.value
has
'\x1c\x01SERVERA.FOO.BAR.ORG/STAGE\x14\x01SERVERA.foo.bar.org|2188\t\x01Primary\x08\x01Active\x15\x01172.31.33.69|1972\x15\x01SERVERA.foo.bar.org|1972'

The field separator appears to be \x01. However there is smattering of 
\x1c
\x14
\t
\x08
\x15

Not sure why there are these hex characters?

0
Robert Cemper  Jan 21 to Phillip Wu

what you see as \x.... is the hex image of a $LB("SERVERA.FOO.BAR.ORG/STAGE", ......)
try ZZDUMP of any $LB()  and you see length + type + content
\t is the misinterpretation of length x\09
my guess it's the hex_dump of some object 

0
Guillaume Rongier  Jan 22 to Phillip Wu

As Robert said it's because of the list build serialization.

You can give a try to :

https://pypi.org/project/iris-dollar-list/

which is an list build parser in python :

from iris_dollar_list import DollarList

dollar_list_str = b'\x1B\x01SERVERA.FOO.BAR.ORG/STAGE\x1A\x01SERVERA.foo.bar.org|2188\t\x01Primary\x08\x01Active\x13\x01172.31.33.69|1972\x1A\x01SERVERA.foo.bar.org|1972'
dollar_list = DollarList(dollar_list_str)
print(dollar_list)

## $lb("SERVERA.FOO.BAR.ORG/STAGE","SERVERA.foo.bar.org|2188","Primary","Active","172.31.33.69|1972","SERVERA.foo.bar.org|1972")
0