python3 request tracker: list tickets from multiple queues
<p>I'm trying to build a script that will get alle open, new and stalled tickets for multiple queue's from a Best Practical Request Tracker installation. I have the following script:</p>

<pre><code>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import rt
from credentials import *  # Contains rturl, rtuser, rtpass

W = rt.Rt(rturl, rtuser, rtpass)
owners = ['Nobody']
queues = ['queue_a', 'queue_b', 'queue_c']
states = ['Open', 'New', 'Stalled']

def build_query():
    queues_part = "(Queue='{}')".format("'+OR+Queue='".join(queues))
    owners_part = "(Owner='{}')".format("'+OR+Owner='".join(owners))
    states_part = "(Status='{}')".format("'+OR+Status='".join(states))
    query_items = [queues_part, owners_part, states_part]
    raw_query = ("+AND+".join(query_items))
    return raw_query


def gettickets(query):
    try:
        W.login()
        tickets = W.search(raw_query=query)
        return tickets

    except Exception as e:
        print('===&gt; Tickets ophalen mislukt:\n', str(e))

    finally:
        W.logout()


if __name__ == '__main__':
    # to check query for errors
    print(build_query())

    # should return all new, open and stalled tickets in queue_a,b,c
    print(gettickets(build_query()))
</code></pre>

<p>If ran, it will print out the correct query (tested this in RT's query builder, and there it runs fine). However, the returned 'tickets' variable just returns an empty list: []</p>

<p>Since the query itself works fine in RT, and there are no errors thrown I'm not sure how to troubleshoot this. Anyone?</p>

<p>Ps. I use the build_query function because (eventually) the script will receive it's parameters from other script(s).</p>