tags:

views:

27

answers:

1

I want to extract a 7-zip archive in a python script. It works fine except that it spits out the extraction details (which is huge in my case).

Is there a way to avoid this verbose info while extraction? I did not find any "silent" command line option to 7z.

My command is

7z.exe -o some_dir x some_archive.7z

Thanks.

+1  A: 

One possibility would be to spawn the child process with popen, so its output will come back to the parent to be processed/displayed (if desired) or else completely ignored (create your popen object with stdout=PIPE and stderr=PIPE to be able to retrieve the output from the child).

Jerry Coffin
Thanks. That helped. I tried subprocess.Popen. But then my parent process is done before the child returns. I would like to check the returncode of the child before continuing. Am going through docs but let me know if you know how to stall (especially with stdout=PIPE) off hand.
sambha
Got it. popen.communicate does it
sambha