From: Juliana Rodrigueiro Date: Wed, 6 Feb 2019 10:57:52 +0000 (+0100) Subject: Use a more robust condition in wait_for_email_transfer X-Git-Tag: v1.4~9 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=68d12e8a2236824fa081ca324a6e4b53ffcf26ad;p=pyi2ncommon Use a more robust condition in wait_for_email_transfer This solution uses 'postqueue -j' command, which will produce an empty list for stdout only when there are no more emails in the queue. We become independent of the format of the output (byte, string, specific characters, etc) --- diff --git a/src/arnied_wrapper.py b/src/arnied_wrapper.py index fc5dc1b..c1666bd 100644 --- a/src/arnied_wrapper.py +++ b/src/arnied_wrapper.py @@ -314,7 +314,7 @@ def wait_for_email_transfer(timeout=300, vm=None): run_cmd(cmd='postqueue -f', vm=vm) log.info('Waiting for SMTP queue to be empty (%i/%i sec)', i, timeout) - if b'Mail queue is empty' in run_cmd(cmd='mailq', vm=vm).stdout: + if not run_cmd(cmd='postqueue -j', vm=vm).stdout: break time.sleep(1) log.debug('SMTP queue is empty')