2

Hi how do i display a progress bar using tqdm while running a subprocess, And instead of displaying the standard update, Display the progress bar instead until complete?

import os
import sys
import subprocess

def update_system():
    subprocess.Popen( 'sudo apt-get -y update',
               shell=True,
               stdin=subprocess.PIPE ).communicate()
    subprocess.Popen( 'sudo apt-get -y upgrade',
               shell=True,
               stdin=subprocess.PIPE ) .communicate() 

I'm sorry if this post is bad it's my first time posting here. I basically want to run the above then do something like

while update_system = running
      display_progress bar
      until complete

         
  • 2
    Keep in mind: How would you know what will be updated, the packet-sizes, the ntw-speed to the CDNs etc., etc. in order to estimate the progress of the bar? **The only thing you could do is a spinner IMO..** – iLuvLogix Dec 07 '20 at 14:31
  • How would i create a spinner for it? that's what i was wondering about load times, and download times. – peter evans Dec 07 '20 at 14:33
  • In the terminal i also want it displayed instead of the update if possible? – peter evans Dec 07 '20 at 14:35
  • You need to silent your update: `-qq` -> No output except for errors.. To get the basic idea have a look here and adjust to your needs: https://stackoverflow.com/questions/47234947/spinner-animation-and-echo-command – iLuvLogix Dec 07 '20 at 14:36
  • Thank you not sure how to replicate in python though – peter evans Dec 07 '20 at 14:38
  • np ;) Just try and play around a bit, you might also find helpful info on https://unix.stackexchange.com/ – iLuvLogix Dec 07 '20 at 14:40
  • Follow this post This might help you https://stackoverflow.com/questions/5429577/showing-progress-while-spawning-and-running-subprocess – Sachin Rajput Dec 07 '20 at 14:56

0 Answers0