Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add verbose flag #247

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pipcompilemulti/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,23 @@ def create_lockfile(self):
if sink_out_path and sink_out_path != self.outfile:
original_in_file = self._read_infile()
self._inject_sink()

verbose = True
process = subprocess.Popen(
self.pin_command,
stdout=subprocess.PIPE,
Copy link

@graingert graingert Mar 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the stdout is captured only for logging it later, so we could just set: stdout=None (the subprocess inherits stdout) and then skip logging stdout in verbose mode

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the stdout=None here gives:

Traceback (most recent call last):
  File "/Users/john/.virtualenvs/pip-compile-multi-demo/lib/python3.8/site-packages/pipcompilemulti/cli_v1.py", line 26, in cli
    recompile()
  File "/Users/john/.virtualenvs/pip-compile-multi-demo/lib/python3.8/site-packages/pipcompilemulti/actions.py", line 30, in recompile
    compile_topologically(env_confs, deduplicator)
  File "/Users/john/.virtualenvs/pip-compile-multi-demo/lib/python3.8/site-packages/pipcompilemulti/actions.py", line 39, in compile_topologically
    if env.maybe_create_lockfile():
  File "/Users/john/.virtualenvs/pip-compile-multi-demo/lib/python3.8/site-packages/pipcompilemulti/environment.py", line 50, in maybe_create_lockfile
    self.create_lockfile()
  File "/Users/john/.virtualenvs/pip-compile-multi-demo/lib/python3.8/site-packages/pipcompilemulti/environment.py", line 74, in create_lockfile
    output = process.stdout.readline()
AttributeError: 'NoneType' object has no attribute 'readline'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you won't need to use process.stdout anymore as it should be sent to the terminal already

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my that makes it simpler

stderr=subprocess.PIPE,
stderr=None if verbose else subprocess.PIPE,
)
if verbose:
while True:
output = process.stdout.readline()
if output == b'' and process.poll() is not None:
break
if output:
print(output.strip())
# TODO: Decide what to do about this
# stdout, stderr = process.poll(), None

stdout, stderr = process.communicate()
finally:
if original_in_file:
Expand Down