From 383c9af291adc90f22232c5398d4e6b7a8167d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20P=C5=82azie=C5=84ski?= Date: Sat, 20 Feb 2016 16:08:46 +0100 Subject: [PATCH] using subprocess instead of os.system --- napi | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/napi b/napi index 1c7bf48..0d722bb 100755 --- a/napi +++ b/napi @@ -21,6 +21,7 @@ import urllib2 import xml.etree.ElementTree as ET import base64 +import subprocess base_url = "http://napiprojekt.pl/api/api-napiprojekt3.php" password = "iBlm8NTigvru0Jr0" @@ -56,7 +57,20 @@ def download_subtitles(digest): input_file.write(base64.b64decode(content)) nazwa = movie_filename[:-4]+'.srt' - if (os.system("/usr/local/bin/7z x -y -so -p" + password + " " + input_filename + " 2>/dev/null >\""+nazwa+"\"")): + executed = [ + '/usr/bin/7z', # executable + 'x', # command: extract + '-p' + password, # use password + '-y', # assume yes on all queries + '-so', # into standard out + input_filename, # input file + ] + + with open(nazwa, "w") as output_file: + process = subprocess.Popen(executed, stdout=output_file) + result = process.wait() + + if result != 0: print "nie ma napisa do filmu", sys.argv[1] os.remove(nazwa) else: