0

I have a CLI program (a downloader) which is returning the following line when operating :

[*..........] xx.x% yyy,yyMb out of zzz,zzMb

I am launching this with a subprocess in Python, and I'd like to know how I can capture the output and how I can selectively get: - the percentage info - the downloaded amount in Mb info - the total size of the file in Mb

Appreciate your help (Python 2.6 compatible solution, please).

ekianjo
  • 31
  • 1
  • 4
  • 1
    This might help - http://stackoverflow.com/questions/803265/getting-realtime-output-using-subprocess – shad0w_wa1k3r Dec 12 '13 at 06:21
  • Thanks, it provides only one part of the answer though. How do I get the % and size out of the stdout ? – ekianjo Dec 12 '13 at 09:00
  • You could use the [`re` module](http://docs.python.org/2/library/re.html#module-contents), or if you really know the format & don't want to indulge in regular expressions, simple `str.split("%")` might do the trick. – shad0w_wa1k3r Dec 12 '13 at 09:04

0 Answers0