Question
· 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 23 2021, 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()
Python
Python

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")
ObjectScript
ObjectScript

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

Discussion (4)1
Log in or sign up to continue

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?

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")
Python
Python