Does Popen().stdout.close() Return A Value?
I have in the code I maintain: app7z = dirs['mopy'].join('7z.exe').s # path to 7z.exe command = ''%s' a '%s' -y -r '%s\\*'' % (app7z, dstFile.temp.s, srcDir.s) ins = Popen(command,
Solution 1:
What do you think, close
can return?
You probably want to use wait
to get the exit code:
app7z = dirs['mopy'].join('7z.exe').s # path to 7z.exe
command = [app7z, 'a', dstFile.temp.s, "-y", "-r", os.path.join(src.Dir.s, '*')]
process = Popen(command, stdout=PIPE, startupinfo=startupinfo)
out = process.stdout
regMatch = re.compile('Compressing\s+(.+)').match
regErrMatch = re.compile('Error: (.*)').match
errorLine = []
for line in out:
maCompressing = regMatch(line)
if len(errorLine) or regErrMatch(line):
errorLine.append(line)
if maCompressing:
# update progress
result = process.wait()
if result:
dstFile.temp.remove()
raise StateError(_("%s: Compression failed:\n%s") % (dstFile.s,
"\n".join(errorLine)))
Post a Comment for "Does Popen().stdout.close() Return A Value?"