Reputation: 469
I'm excuting a python script that utilizes patool
library (a library for creating/extracting compressed archives).
The thing is that when I run the script, it gives me the following lines:
patool: Extracting D:/xx/xx/xx.xml.gz
patool: running "C:\Program Files\7-Zip\7z.EXE" e -o D:/xx/xx/ -- D:/xx/xx/xx.xml.gz
patool: ... D:/xx/xx/ -- xx.xml.gz extracted to D:/xx/xx/
These obviusly are not error lines. They just tell me what's going on. I need to hide these lines when excuting the script. But ONLY this message, I mean NOT other type of messages, like error messages for example.
Upvotes: 2
Views: 1489
Reputation: 4572
After some reading I've found an easy fix to this annoying problem. The fix is in their documentation. As you can see in their source code (at this time, line 679), patool
only print messages when verbosity
option is equal or greater than 0
:
def extract_archive(archive, verbosity=0, outdir=None, program=None, interactive=True):
"""Extract given archive."""
util.check_existing_filename(archive)
if verbosity >= 0:
util.log_info("Extracting %s ..." % archive)
return _extract_archive(archive, verbosity=verbosity, interactive=interactive, outdir=outdir, program=program)
So, in order to fix your problem and hide all standard prints from patool
use:
patoolib.extract_archive(path_to_file, outdir=path_to_unzip, verbosity=-1)
Instead of:
patoolib.extract_archive(path_to_file, outdir=path_to_unzip)
Hope this helps :)
Upvotes: 5