I implemented something similar inside the sge plugin, looks like:

    def _get_number_of_slots(self,node):
        """
        get number of slots for the given node by parsing qconf -sq all.q
        """

        qconf_output = '\n'.join(self._master.ssh.execute('qconf -sq all.q'))
        slots =  int(re.search("%s=[0-9]+" % node.alias,qconf_output).group(0).split('=')[1])

        return slots

It's still a bit messy, but saves having to write to file.