On 13/06/16 17:50, Ramanathan Muthaiah wrote: > Am aware of the module called 'progressbar' that can do this magic of > displaying progress as the cmd is executed.
I'm not familiar with it, I don't believe its in the standard library? So I can only offer generalized advice. > def main(): > progress = ProgressBar() > for num in progress(range(80)): > time.sleep(0.15) I have no idea how that works since I don;t know anything about the progress API. Its apparently callable and takes a sequence and returns a sequence but what it does with those values I can't say. > And, I have this piece of code that executes set of cmds > This too works without any issues until now. > > try: > dlog = subprocess.check_output([cmd], > stderr=subprocess.STDOUT, shell=True) > except subprocess.CalledProcessError, e: > dlog = e.output > > Question: > > Am lost as to how to combine the progressbar and subprocess code snippets Here's where the generalized help comes in. There are two common approaches: 1) Split your work into bite sized chunks. Repeatedly call those chunks until done and update progress after each chunk. 2) Run your work in a separate thread and in the main thread update the progress bar either based on an estimated time to complete or by reading the process output in some way. How that translates to your particular ProgressBar I can't say. But it might give you ideas. Or maybe the start of a specific question to the module support forum/list or author -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor