Use a more robust condition in wait_for_email_transfer
authorJuliana Rodrigueiro <juliana.rodrigueiro@intra2net.com>
Wed, 6 Feb 2019 10:57:52 +0000 (11:57 +0100)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Thu, 7 Feb 2019 15:50:39 +0000 (16:50 +0100)
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)

src/arnied_wrapper.py

index fc5dc1b..c1666bd 100644 (file)
@@ -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')