Written by

Question Kevin McGinn · Sep 19, 2022

Python method; issues with status returned from run_class_method

In my Python script I import intersys2.pythonbind3 to create the connection and define a database object as db

I execute the method 

     res = self.db.run_class_method("%Library.GlobalEdit", "GetGlobalSize",[<db>, allocated,used])

This executes correctly as I loop through a list of databases.

Upon success I see that the return arg of "res" contains the string "status(0,)" which I interpret as successful. This is verified by the returned values of allocated and used being accurate. But I want to use the class/methods to get the status values from the returned structure

In reading the documents, I thought the statement:

    status = self.db.run_class_method('%SYSTEM.Status', 'IsError', [res])

would return a value of 1 on error, but this statement always returns 1;  even when res='status(0,)' which is indicative of success.

Any ideas about what I am missing or doing incorrectly?

Product version: Caché 2017.1

Comments

Eduard Lebedyuk · Sep 19, 2022

The only success status is 1.

Anything else is an error or invalid status.

0
Kevin McGinn  Sep 19, 2022 to Eduard Lebedyuk

That is my point of confusion. The 'IsError' method returns a value of 1 which indicates an error. But the run_class_method() is returning valid allocated and used global sizes for the specified global. I am unclear how I am getting valid results and an error. These would seem to be mutually exclusive.

0
Eduard Lebedyuk  Sep 19, 2022 to Kevin McGinn

Have you tried executing the same code from the InterSystems terminal?

Also try:

text = self.db.run_class_method("%SYSTEM.Status", "GetErrorText", res)
print(text)
0
Robert Cemper · Sep 19, 2022

Class Reference of %SYSTEM.Status says:
classMethode IsError(statuscode As %Status) as %Boolean

Returns 1 if the statuscode contains errors. Otherwise, it returns 0.

 So if you get  [res] as  (0,....)  it is an ERROR!  
and therefore the result ofIsError should be 1.  It is an Error.

0
Kevin McGinn · Sep 20, 2022

Ok, trying to isolate my syntax error. I have re-reviewed the class specs but I am not seeing an issue. I have this:

    allocated = 0
    used      = 0
    db          = "/data/testdb/"
    global      = "STRELPERF"
    
    # Set args to pass by reference
    list = [db,global,allocated,used]

    # exec the class method to get the global size
    res = self.db.run_class_method("%Library.GlobalEdit", "GetGlobalSize",list)

This is the call that returns the failure status of res(0,). The associated error text is :

ERROR #00: (no error description)

Since for other databases that do not contain the global I get the error:

ERROR #308: Global STRELPERF not found.

It seems that code clip is close but something that I am not seeing is missing. Any help would be appreciated.

0