system.alarm.queryStatus with multiple source paths

Hello,

Can anyone explain to me how to pass this function multiple paths including wildcards. I have tried a comma seperated list with no luck.

Thanks,

Frank

You need to pass in a list of paths
Eg.

["*hello", "*world"]
1 Like

I am seeing some odd behavior here.

> This works: *ABC123*
> This works: [*ABC123*]
> This does not work: "*ABC123*"
> This does not work: ["*ABC123*"]
> This does not work: ["*ABC123*","*CDE456*"]

Any ideas? Also I am calling this function from a script module and passing the filter into the function FWIW.

Thanks,

Frank

What’s *ABC123* here ? Is it already a string ? can you tell us what type(*ABC123*) returns ?

def hasActiveUnack(Filter):
    import system
    try:
        if len(system.alarm.queryStatus(source=str(Filter),state = ["ActiveUnacked"])) > 0:
            return type(Filter)
        else:
            return type(Filter)
    except:
        return 0

def hasActiveAck(Filter):
            import system
            try:
                if len(system.alarm.queryStatus(source=str(Filter),state = ["ActiveAcked"])) > 0:
                    return type(Filter)
                else:
                    return type(Filter)
            except:
                return 0
def hasClearUnack(Filter):
            import system
            try:
                if len(system.alarm.queryStatus(source=str(Filter),state = ["ClearUnacked"])) > 0:
                    return type(Filter)
                else:
                    return type(Filter)

            except:
                return 0

Here are my script functions, modified temporarily to return type

It returns back class org.python.core.PyUnicode

It is definitely related to passing the source list into the function. If I hard code source=["*ABC123*","*CDE345*"] it works fine.

You may find it beneficial to call system.alarm.queryStatus once vs multiple times. You can get away with it if you aren’t calling it that much, but 100s of times and you might start seeing lag.

While I agree with this statement my issue seems to be syntactical in nature. I surely cannot be the first person to call system.alarm.queryStatus inside a function passing in source or display path.

Indeed.

When you call system.alarm.queryStatus() you’re using str(Filter) which will try to convert whatever filter is to a string. So when you send ["*abc123*"] it gets converted to the string
"['*abc123*']"
which isn’t valid.

However, you asked how to pass the function multiple paths including wildcards,but your script is attempting to pass multiple sources. Which are you really wanting to do?

To pass multiple paths the correct syntax is:

flt = ['*abc123*','*CDE456*']
system.alarm.queryStatus(path=flt) #set state and/or priority as needed
1 Like

I question why youre converting the filter into a string? This is why it’s not working, as you’re not passing a list into the function

Yes, this was a foobar on my part, I have since corrected it and have it working properly. Thanks for the replies.

Frank