wummel / patool

patool is a portable command line archive file manager
http://wummel.github.io/patool/
GNU General Public License v3.0
404 stars 68 forks source link

Fixing command line output in list_archive() method #142

Closed ssolidsnake closed 9 months ago

ssolidsnake commented 11 months ago

The list_archive method doesn't display the command line output, whether by using the library or the command line (patool list <file_to_path>)

OS: Windows 10.0.19045 IDE: VSCode 1.85.0

You need to remove subprocess.DEVNULL in the run method, but this will display what comes out from the output everytime your run any function (even extract_archive()).

To fix this, I set the verbosity to 2 in the list_archive() method and two conditions in the run method, one to change stdout in the subprocess.run from DEVNULL to PIPE (More explanations in the comments), and another one to display the output only when list_archive is called.

Both patoolib.py and cli.py are both fixed and works perfectly. This is my first contribution, I hope this is a good fix for the issue, but if you have a better fix, I'd love to see how more experienced programmers solve their problems.

wummel commented 9 months ago

I cannot reproduce this, the current version of patool should work as-is. Can you check which version of patool you are using, or post the exact command?

In the most recent version, subprocess.DEVNULLwill only be used when verbosity is zero or less, see here: https://github.com/wummel/patool/blob/8358491e7f9cabcbf3728cc490525ef925fd4cb1/patoolib/util.py#L84

And in patoolib/cli.py and patoolib/__init__.py the default verbosity for list_archive() is 1: https://github.com/wummel/patool/blob/97b1efbf810061ebee0befbfaeec067dc6472f7d/patoolib/__init__.py#L748 https://github.com/wummel/patool/blob/8358491e7f9cabcbf3728cc490525ef925fd4cb1/patoolib/cli.py#L56

wummel commented 9 months ago

A new version 2.2.0 of patool has been released on 14.02.2024. Therefore this bug will be closed. If you think this issue is not solved, please open a new issue.