Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98618
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Tim Johnson <tim@akwebsoft.com> |
| Newsgroups | comp.lang.python |
| Subject | Using subprocess to capture a progress line |
| Date | Tue, 10 Nov 2015 13:47:56 -0900 |
| Organization | AkWebsoft |
| Lines | 55 |
| Message-ID | <mailman.224.1447196174.16136.python-list@python.org> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| X-Trace | news.uni-berlin.de m9Q3vnbGltskGyaTAtU46AmhuWhfW5Wts0YEBUoPrCug== |
| Return-Path | <tim@akwebsoft.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.009 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'bash': 0.07; 'finished.': 0.07; 'line:': 0.07; 'newline': 0.07; 'tmp': 0.07; '###': 0.09; 'python': 0.10; 'output': 0.13; 'carriage': 0.16; 'collins': 0.16; 'manifest': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subprocess': 0.16; 'true:': 0.16; 'uses,': 0.16; 'app': 0.16; 'runs': 0.18; "aren't": 0.22; 'player': 0.23; 'tim': 0.24; 'written': 0.24; "i've": 0.25; 'header:User-Agent:1': 0.26; 'command': 0.26; 'question': 0.27; 'executing': 0.27; 'function': 0.28; 'command-line': 0.29; 'container': 0.29; 'follows': 0.29; 'print': 0.30; 'code': 0.30; 'run': 0.33; 'clarify': 0.33; 'downloading': 0.33; 'ubuntu': 0.33; "i'll": 0.33; 'file': 0.34; 'running': 0.34; 'info': 0.34; 'i.e.': 0.35; 'but': 0.36; 'there': 0.36; 'lines': 0.36; 'to:addr:python-list': 0.36; 'being': 0.37; 'method': 0.37; 'thanks': 0.37; 'charset:us-ascii': 0.37; 'progress': 0.38; 'reports': 0.38; 'does': 0.39; 'application': 0.39; 'skip:- 60': 0.39; 'to:addr:python.org': 0.40; 'show': 0.62; 'video': 0.62; 'information': 0.63; 'times': 0.63; 'soon': 0.65; 'numerous': 0.66; 'webpage': 0.66; '100%': 0.72; 'correcting': 0.84; 'subject:Using': 0.84; 'fyi': 0.91; 'judy': 0.91 |
| Mail-Followup-To | Python ML <python-list@python.org> |
| Content-Disposition | inline |
| 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:98618 |
Show key headers only | View raw
Using python 2.7.6 on ubuntu 14.04
The application in question is run with bash and gnome-terminal :
I've written a command-line "wrapper" for youtube-dl, executing
youtube-dl as a subprocess.
------------------------------------------------------------------
youtube-dl reports download progress on one line. I.E. the line is
overwritten numerous times with no carriage return until the
downloading is finished.
------------------------------------------------------------------
The following code runs the youtube-dl command and reports each line
as output by youtube-dl
###########
p = subprocess.Popen(list(args), stderr=subprocess.STDOUT,
stdout=subprocess.PIPE)
while True:
line = p.stdout.readline()
if not line:
break
tmp = line.strip()
print tmp
###########
However this method not does show the download progress _until_ the
download is complete.
To clarify : follows is output from my app running youtube-dl.
I've annotated the line in question with '###'
[youtube] ZIgnHPqp0Dk: Downloading webpage
[youtube] ZIgnHPqp0Dk: Downloading video info webpage
[youtube] ZIgnHPqp0Dk: Extracting video information
[youtube] ZIgnHPqp0Dk: Downloading js player en_US-vfljDEtYP
[youtube] ZIgnHPqp0Dk: Downloading DASH manifest
[download] Destination: Someday Soon - Judy Collins 1969.avi.m4a
### the line below is not seen until download is finished.
[download] 100% of 7.58MiB in 00:12.85KiB/s ETA 00:00
[ffmpeg] Correcting container in "Someday Soon - Judy Collins 1969.avi.m4a"
[ffmpeg] Destination: Someday Soon - Judy Collins 1969.avi.mp3
Deleting original file Someday Soon - Judy Collins 1969.avi.m4a (pass -k to keep)
Is there a way to code subprocess so the the progress is being
shown? In my case lines being output aren't being shown unless a
newline is sent, or so I understand it.
FYI : the need for this function in this case is trivial, but the
solution will be enlightening for me and have other uses, I'll bet.
thanks
--
Tim
http://www.akwebsoft.com, http://www.tj49.com
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Using subprocess to capture a progress line Tim Johnson <tim@akwebsoft.com> - 2015-11-10 13:47 -0900
csiph-web