Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98645

Re: Using subprocess to capture a progress line

From Tim Johnson <tim@akwebsoft.com>
Newsgroups comp.lang.python
Subject Re: Using subprocess to capture a progress line
Date 2015-11-11 07:16 -0900
Organization AkWebsoft
Message-ID <mailman.244.1447258619.16136.python-list@python.org> (permalink)
References <20151110224756.GA1944@mail.akwebsoft.com> <CAMw+j7LZH44RnPXgP4XVDiv62uJ_iFmsEm17QpsmNBSDr=uvJw@mail.gmail.com>

Show all headers | View raw


* Chris Warrick <kwpolska@gmail.com> [151111 00:55]:
> On 10 November 2015 at 23:47, Tim Johnson <tim@akwebsoft.com> wrote:
> > Using python 2.7.6 on ubuntu 14.04
<..> 
> There is no \n character at the end — which means that
> p.stdout.readline() cannot return. In fact, if you printed repr() of
> the line you read, you would get this:
> 
> b'\r[download]  54.9% of 2.73MiB at 26.73KiB/s ETA 00:47\r[download]
> 55.0% of 2.73MiB at 79.33KiB/s ETA 00:15\r…snip…\r[download] 100% of
> 2.73MiB in 00:01\n'
> 
> The download line is implemented using \r, which is the carriage
> return character (return to the first character), and then by
> overwriting characters that were already printed.
> 
> The solution? There are numerous. I’ll help you by obscuring the worst one.
> 
> (1) [recommended] figure out how to make youtube_dl work as a library,
> read its main file to figure out the problem. Don’t mess with
> subprocess.
  Was my first goal, had some problems, but I have solved them in
  part by finding the good documentation of the developers.

  I.E., the subprocess method _is_ going away and I will be using
  the youtube_dl module.

> (2) [don’t do it] do you need to intercept the lines? If you don’t set
> stderr= and stdout=, things will print just fine.
  Got to try that before using the module, just for edification.

> (3) [DON’T DO IT] .ernq() punenpgre ol punenpgre naq znxr n zrff.
> 
> PS. Thank you for setting a sensible Reply-To header on your messages.
> Which is something the list should be doing.
  LOL! Glad to help :)
  Thanks for the reply and the further education. 
  Cheers
-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Using subprocess to capture a progress line Tim Johnson <tim@akwebsoft.com> - 2015-11-11 07:16 -0900

csiph-web