Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing output of apt-get install for progress bar

I'm working on a simple GUI Python script to do some simple tasks on a system. Some of that work involves apt-get install to install some packages.

While this is going on, I want to display a progress bar that should update with the progress of the download, using the little percentage shown in apt-get's interface in the terminal.

BUT! I can't find a way to get the progress info. Piping or redirecting the output of apt-get just gives static lines that show the "completed download" message for each package, and same for reading via subprocess.Popen() in my script.

How can I read from apt-get's output to get the percentages of the file downloaded?

like image 804
Grant Paul Avatar asked Nov 07 '09 05:11

Grant Paul


1 Answers

Instead of parsing the output of the apt-get, you can use python-apt to install packages. AFAIK it also has modules for reporting the progress.

like image 61
Vihang D Avatar answered Sep 28 '22 09:09

Vihang D