2

I'm excuting a python script that utilizes patoollibrary (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.

2 Answers 2

5

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 :)

Sign up to request clarification or add additional context in comments.

Comments

0

I think what you need is to use a logging library (like logging). Thus, you isolate the information due to the script's behavior (info/succes/errors) from the output of the script (what you want to show).

1 Comment

To clarify for others who might have made the same mistake as I: that's verbosity = -1, not verbosity = +1. Thanks for the help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.