Example #1
0
        def get_queue_items(self, queue_name):
            """Determines if the queue exists and if so the message count.

            If the queue exists the return value is an integer, otherwise
            its None.

            Be careful because queue_name is used in a regex and can't have
            any unescaped characters.

            """
            proc = start_proc(["/usr/bin/sudo", "rabbitmqctl", "list_queues"],
                              shell=False)
            for line in iter(proc.stdout.readline, ""):
                print("LIST QUEUES:" + line)
                m = re.search(r"%s\s+([0-9]+)" % queue_name, line)
                if m:
                    return int(m.group(1))
            return None
Example #2
0
 def run(self, check_exit_code, *cmd):
     cmds = ["/usr/bin/sudo"] + list(cmd)
     proc = start_proc(cmds)
     lines = proc.stdout.readlines()
     err_lines = proc.stderr.readlines()
     return lines, err_lines