'This method parses qstat -xml output and makes a neat array'

def parse_qstat(self, qstat_out):

    self.jobs = []
    self.queues = {}
    doc = xml.dom.minidom.parseString(qstat_out)
    for q in doc.getElementsByTagName('Queue-List'):
        name = q.getElementsByTagName('name')[0].childNodes[0].data
        slots = q.getElementsByTagName('slots_total')[0].childNodes[0].data
        self.queues[name] = dict(slots=int(slots))
        for job in q.getElementsByTagName('job_list'):
            self.jobs.extend(self._parse_job(job, queue_name=name))
    for job in doc.getElementsByTagName('job_list'):
        if (job.parentNode.nodeName == 'job_info'):
            self.jobs.extend(self._parse_job(job))
    return self.jobs
