I've written what I thought was a simple python script to search through several lines of output and match (i.e. "grep") on a specific string. Listing all queues without the pattern match is simple enough:
from qmf.console import Session
sess = Session()
broker = sess.addBroker("amqp://guest/guest@localhost")
queues = sess.getObjects(_class="queue", _package="org.apache.qpid.broker")
for q in queues:
print (q)
Running the script produces the following output (truncated):
pmena@myhost=> python ./queue_stuff.py
org.apache.qpid.broker:queue[0-1-1-0-62] 0-1-1-0-3:queue01
org.apache.qpid.broker:queue[0-1-1-0-55] 0-1-1-0-3:queue02
org.apache.qpid.broker:queue[0-1-1-0-63] 0-1-1-0-3:queue03
org.apache.qpid.broker:queue[0-1-1-0-51] 0-1-1-0-3:queue04
.
.
org.apache.qpid.broker:queue[0-1-1-0-51] 0-1-1-0-3:queue99
However when I add an "if" statement to match on a particular string, like so:
from qmf.console import Session
sess = Session()
broker = sess.addBroker("amqp://guest/guest@localhost")
queues = sess.getObjects(_class="queue", _package="org.apache.qpid.broker")
for q in queues:
if 'queue37' in q:
print (q)
I get the following error:
pmena@myhost=> python ./queue_stuff.py
Traceback (most recent call last):
File "./queue_stuff.py", line 6, in <module>
if 'queue37' in q:
TypeError: argument of type 'Object' is not iterable
I feel like this is a simple python syntax issue, but wasn't able to glean the resolution from other posts.