From bf2931c9491ed9d9155dbd97feb48ac5fb0bde49 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 23 Aug 2017 22:22:54 +0300 Subject: [PATCH] Use subprocess.Popen instead of os.popen --- mimedecode.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mimedecode.py b/mimedecode.py index 3b1df3e..9433b0d 100755 --- a/mimedecode.py +++ b/mimedecode.py @@ -2,6 +2,7 @@ """Decode MIME message""" import sys, os +import subprocess from mimedecode_version import __version__, \ __author__, __copyright__, __license__ if sys.version_info[0] >= 3: @@ -250,9 +251,10 @@ def decode_body(msg, s): outfile.write(s) outfile.close() - pipe = os.popen(command, 'r') - new_s = pipe.read() - if pipe.close() is None: # result=0, Ok + pipe = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) + new_s = pipe.stdout.read() + pipe.stdout.close() + if pipe.wait() == 0: # result=0, Ok s = new_s os.remove(filename) -- 2.39.5