How Can I Call %SYSTEM class methods from Embedded Python?
Hi, devs!
What's the way to call the methods of %SYSTEM class from python?
I tried this way:
print(iris.cls('_SYSTEM.OBJ').Version())
and getting an error: Traceback (most recent call last): File "<input>", line 1, in <module> RuntimeError: iris.class: error finding class
Here is how it works in ObjectScript:
USER>w ##class(%SYSTEM.OBJ).Version()
InterSystems IRIS Version 2022.1.0.209
USER>
Thoughts?
Product version: IRIS 2022.1
You don't need to change the "%" to a "_" in this instance as the cls method is being passed a string literal. This works fine:
print(iris.cls('%SYSTEM.OBJ').Version()) InterSystems IRIS Version 2022.1.0.209
That’s a bit confusing with “%” method names like %New() and %Save() that are supposed to called as _New() and _Save() via python , but makes sense. Thank you @Jolyon Smith!
You can also use the iris.system object in python.
iris.system.Version.GetVersion() returns the full version ($ZV)
IRIS for UNIX (Ubuntu Server LTS for x86-64 Containers) 2022.2 (Build 356U) Thu Oct 6 2022 22:56:28 EDT
There are other methods here to call to such as GetMajor() which would return '2022' and GetPlatform() which returns 'Ubuntu Server LTS for x86-64 Containers'
do dir(iris.system.Version) at the python shell to see them all.
Wow! That's cool! Didn't know that, thank you @Rich Taylor!