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

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Tim Johnson <tim@akwebsoft.com>
Newsgroups comp.lang.python
Subject Re: Using subprocess to capture a progress line
Date Wed, 11 Nov 2015 07:16:57 -0900
Organization AkWebsoft
Lines 41
Message-ID <mailman.244.1447258619.16136.python-list@python.org> (permalink)
References <20151110224756.GA1944@mail.akwebsoft.com> <CAMw+j7LZH44RnPXgP4XVDiv62uJ_iFmsEm17QpsmNBSDr=uvJw@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de 5YCu1COBYW1X+zdBes59NgQXYThnLp7MoqjOcRkM1unA==
Return-Path <tim@akwebsoft.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'messages.': 0.04; 'mess': 0.09; '\xe2\x80\x94': 0.09; 'python': 0.10; 'carriage': 0.16; 'goal,': 0.16; 'i.e.,': 0.16; 'naq': 0.16; 'overwriting': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'repr()': 0.16; 'subprocess': 0.16; 'worst': 0.16; 'wrote:': 0.16; 'library,': 0.18; 'module,': 0.18; '2015': 0.20; 'developers.': 0.22; 'this:': 0.23; 'cheers': 0.24; 'implemented': 0.24; 'tim': 0.24; 'header :In-Reply-To:1': 0.24; 'header': 0.24; 'header:User-Agent:1': 0.26; 'chris': 0.26; 'figure': 0.27; 'module.': 0.27; 'reply-to': 0.29; 'sensible': 0.29; 'character': 0.29; 'read,': 0.29; 'print': 0.30; 'skip:[ 10': 0.31; 'ubuntu': 0.33; 'file': 0.34; 'list': 0.34; 'something': 0.35; 'problem.': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; '(3)': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'setting': 0.37; 'thanks': 0.37; '(2)': 0.37; 'johnson': 0.37; 'things': 0.38; '(1)': 0.38; 'thank': 0.38; 'end': 0.39; 'means': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'your': 0.60; 'further': 0.62; 'fact,': 0.67; 'reply': 0.68; '8bit%:21': 0.70; '100%': 0.72; 'i\xe2\x80\x99ll': 0.84; 'subject:Using': 0.84; 'glad': 0.87; 'ps.': 0.91
Mail-Followup-To python-list@python.org
Content-Disposition inline
In-Reply-To <CAMw+j7LZH44RnPXgP4XVDiv62uJ_iFmsEm17QpsmNBSDr=uvJw@mail.gmail.com>
User-Agent Mutt/1.5.21 (2010-09-15)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:98645

Show key headers only | 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