Popular Python recipes tagged "progress"http://code.activestate.com/recipes/langs/python/tags/progress/2014-05-30T01:10:53-07:00ActiveState Code RecipesMonitor Progress of File Descriptors of Another Process (Python) 2014-05-30T01:10:53-07:00Alfehttp://code.activestate.com/recipes/users/4182236/http://code.activestate.com/recipes/578882-monitor-progress-of-file-descriptors-of-another-pr/ <p style="color: grey"> Python recipe 578882 by <a href="/recipes/users/4182236/">Alfe</a> (<a href="/recipes/tags/file_descriptor/">file_descriptor</a>, <a href="/recipes/tags/monitor/">monitor</a>, <a href="/recipes/tags/prediction/">prediction</a>, <a href="/recipes/tags/proc/">proc</a>, <a href="/recipes/tags/process/">process</a>, <a href="/recipes/tags/progress/">progress</a>, <a href="/recipes/tags/watch/">watch</a>). </p> <p>This tool (inspired by azat@stackoverflow, see <a href="http://stackoverflow.com/a/16082562/1281485" rel="nofollow">http://stackoverflow.com/a/16082562/1281485</a>) allows to watch the progress of the file descriptors of another process. This can be used, for example, if you transfer a file to another host and the transferring program does not show any progress indication itself. Instead of waiting blindly until the routine is done, with this tool you can use Linux's proc file system to monitor the progress of the other process while it walks through the file.</p> <p>The tool continuously monitors the position in and the size of the files the given process's file descriptors point to. For growing (or shrinking, but that's very unusual) files, a time when it was (or will be) empty is computed ("emptyTime"), for moving file descriptors (the typical case), the time when it started at position 0 ("startTime"), the time when it will reach the current size of the file ("reachTime") and when it will meet with the end of a growing (or shrinking) file is computed ("meetTime").</p> <p>For fixed-size files the meetTime will be the same as the reachTime of course. The meetTime only makes sense in case a file is growing and at the same time read (e. g. when a movie is downloaded to a file by one process and converted by a different process; using this tool can tell you when the converter process might run dry on the input because the download wasn't fast enough, and in this case you maybe can pause the converter to prevent this situation).</p> <p>The tool is designed as a library; the display of the information is independent from the gathering of the data. Please feel free to create more fancy displays, add percentage output etc.</p> Wrap a a file-like object in another that calls a user callback whenever read() is called on it. (Python) 2013-09-25T01:54:53-07:00Martin Millerhttp://code.activestate.com/recipes/users/155538/http://code.activestate.com/recipes/578674-wrap-a-a-file-like-object-in-another-that-calls-a-/ <p style="color: grey"> Python recipe 578674 by <a href="/recipes/users/155538/">Martin Miller</a> (<a href="/recipes/tags/callback/">callback</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/oop/">oop</a>, <a href="/recipes/tags/progress/">progress</a>, <a href="/recipes/tags/upload/">upload</a>). </p> <p>Wraps a file-like object in another, but also calls a user callback with the number of bytes read whenever its <code>read()</code> method is called. Used for tracking upload progress, for example for a progress bar in a UI application.</p> Wrap a string in a file-like object that calls a user callback whenever read() is called on the stream (Python) 2013-09-22T21:48:03-07:00Ben Hoythttp://code.activestate.com/recipes/users/4170919/http://code.activestate.com/recipes/578669-wrap-a-string-in-a-file-like-object-that-calls-a-u/ <p style="color: grey"> Python recipe 578669 by <a href="/recipes/users/4170919/">Ben Hoyt</a> (<a href="/recipes/tags/callback/">callback</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/progress/">progress</a>, <a href="/recipes/tags/upload/">upload</a>). </p> <p>Wraps a string in a read-only file-like object, but also calls a user callback with the number of bytes read whenever <code>read()</code> is called on the stream. Used for tracking upload progress, for example for a progress bar in a UI application.</p> Progress bar class (Python) 2012-08-09T17:39:10-07:00Xavier L.http://code.activestate.com/recipes/users/4171602/http://code.activestate.com/recipes/578228-progress-bar-class/ <p style="color: grey"> Python recipe 578228 by <a href="/recipes/users/4171602/">Xavier L.</a> (<a href="/recipes/tags/class/">class</a>, <a href="/recipes/tags/cli/">cli</a>, <a href="/recipes/tags/curses/">curses</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/module/">module</a>, <a href="/recipes/tags/progress/">progress</a>). Revision 5. </p> <p>See <a href="https://gist.github.com/3306295">gist:3306295</a> for future developments.</p> <p>Here is a little class that lets you present percent complete information in the form of a progress bar using the '=' character to represent completed portions, spaces to represent incomplete portions, '>' to represent the current portion and the actual percent done (rounded to integer) displayed at the end:</p> <p>[===========&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;] 60%</p> <p>When you initialize the class, you specify the minimum number (defaults to 0), the maximum number (defaults to 100), and the desired width of the progress bar. The brackets <code>[]</code> are included in the size of the progress bar, but you must allow for up to 4 characters extra to display the percentage.</p> <p>You'd probably want to use this in conjuction with the curses module, or something like that so you can over-write the same portion of the screen to make your updates 'animated'.</p> Python Progressbar (Python) 2011-09-18T18:57:48-07:00Anler Hernández Peralhttp://code.activestate.com/recipes/users/4176323/http://code.activestate.com/recipes/577871-python-progressbar/ <p style="color: grey"> Python recipe 577871 by <a href="/recipes/users/4176323/">Anler Hernández Peral</a> (<a href="/recipes/tags/progress/">progress</a>). </p> <p>A progressbar utility for command line programs, very easy to use. The original code is hosted in github: <a href="https://github.com/ikame/progressbar" rel="nofollow">https://github.com/ikame/progressbar</a></p> Simple Cli Progress Bar (Python) 2011-11-22T22:00:44-08:00Samuele Millevoltehttp://code.activestate.com/recipes/users/4180021/http://code.activestate.com/recipes/577956-simple-cli-progress-bar/ <p style="color: grey"> Python recipe 577956 by <a href="/recipes/users/4180021/">Samuele Millevolte</a> (<a href="/recipes/tags/bar/">bar</a>, <a href="/recipes/tags/progress/">progress</a>, <a href="/recipes/tags/progress_bar/">progress_bar</a>, <a href="/recipes/tags/python/">python</a>). Revision 2. </p> <p>It's a simple function to print a progress bar under cli. When you call the function you have to indicate the max level that indicates 100% and what has been done considering the max level.</p> Progress Bar for Console Programs as Iterator (Python) 2010-03-26T20:04:02-07:00Michael Grünewaldhttp://code.activestate.com/recipes/users/4172244/http://code.activestate.com/recipes/576986-progress-bar-for-console-programs-as-iterator/ <p style="color: grey"> Python recipe 576986 by <a href="/recipes/users/4172244/">Michael Grünewald</a> (<a href="/recipes/tags/console/">console</a>, <a href="/recipes/tags/cui/">cui</a>, <a href="/recipes/tags/progress/">progress</a>). Revision 6. </p> <p>A small proxy iterator showing a progress bar on the console. Only works with iterators that provide a length (i.e. <code>len(iterator)</code> must be defined).</p> Precise console progress meter with ETA calculation (Python) 2010-04-18T21:11:40-07:00Denis Barmenkovhttp://code.activestate.com/recipes/users/57155/http://code.activestate.com/recipes/577002-precise-console-progress-meter-with-eta-calculatio/ <p style="color: grey"> Python recipe 577002 by <a href="/recipes/users/57155/">Denis Barmenkov</a> (<a href="/recipes/tags/console/">console</a>, <a href="/recipes/tags/eta/">eta</a>, <a href="/recipes/tags/meter/">meter</a>, <a href="/recipes/tags/progress/">progress</a>). Revision 13. </p> <p>After several attempts to use third-party modules I wrote my own console progress meter.</p> <p>Bonus list:</p> <ol> <li>calculation of ETA based on last update points. More accuracy when comparing with calculation ETA based on process start time (process can survive after Hibernate, but ETA has lost his accuracy)</li> <li>ability to write progress meter to sys.stderr</li> <li>update_left() method for multithreaded programs :)</li> </ol> Python to IProgressDialog interface (Python) 2011-02-17T23:04:04-08:00Larry Bateshttp://code.activestate.com/recipes/users/4170897/http://code.activestate.com/recipes/576821-python-to-iprogressdialog-interface/ <p style="color: grey"> Python recipe 576821 by <a href="/recipes/users/4170897/">Larry Bates</a> (<a href="/recipes/tags/com/">com</a>, <a href="/recipes/tags/progress/">progress</a>). Revision 2. </p> <p>Easy method to use Windows Explorer's ProgressDialog COM object to show progress of processing, uploads, downloads, etc.</p> StatusMeter widget for Tkinter (Python) 2009-03-02T19:24:38-08:00Tucker Beckhttp://code.activestate.com/recipes/users/4169378/http://code.activestate.com/recipes/576674-statusmeter-widget-for-tkinter/ <p style="color: grey"> Python recipe 576674 by <a href="/recipes/users/4169378/">Tucker Beck</a> (<a href="/recipes/tags/meter/">meter</a>, <a href="/recipes/tags/progress/">progress</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). </p> <p>Provides a status meter that displays the current status of a running function, percentage completion of that function, and allows cancellation of that function. This helps for long-running tasks that need to run without blocking the GUI and should display their progress to a user.</p> Sensible Loop Status (Python) 2008-10-05T02:14:52-07:00David Lamberthttp://code.activestate.com/recipes/users/4167420/http://code.activestate.com/recipes/576528-sensible-loop-status/ <p style="color: grey"> Python recipe 576528 by <a href="/recipes/users/4167420/">David Lambert</a> (<a href="/recipes/tags/debug/">debug</a>, <a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/logging/">logging</a>, <a href="/recipes/tags/progress/">progress</a>, <a href="/recipes/tags/status/">status</a>). </p> <p>A LoopStatus object tests true according to geometric progression or time intervals. This enables rapid time estimates for long running codes, typically in a loop, without producing copious highly repetitive output.</p>