gummy.utils.monitor_utils module

Utility programs for monitoring loop or time-consuming process.

gummy.utils.monitor_utils.progress_reporthook_create(filename='', bar_width=20, verbose=True)[source]

Create Progress reporthook for urllib.request.urlretrieve

Returns

The reporthook which is a callable that accepts a block number, a read size, and the total file size of the URL target.

Parameters
  • filename (str) – Downloading filename.

  • bar_width (int) – The width of progress bar.

Examples

>>> import urllib
>>> from gummy.utils import progress_reporthook_create
>>> urllib.request.urlretrieve(url="hoge.zip", filename="hoge.zip", reporthook=progress_reporthook_create(filename="hoge.zip"))
hoge.zip        1.5%[--------------------] 21.5[s] 8.0[GB/s]    eta 1415.1[s]
class gummy.utils.monitor_utils.ProgressMonitor(max_iter, verbose=True, barname='', **kwargs)[source]

Bases: object

Monitor the loop progress.

Examples

>>> from pycharmers.utils import ProgressMonitor
>>> max_iter = 100
>>> monitor = ProgressMonitor(max_iter=max_iter, verbose=True, barname="NAME")
>>> for it in range(max_iter):
>>>     monitor.report(it, loop=it+1)
>>> monitor.remove()
NAME 100/100[####################]100.00% - 0.010[s]  loop: 100
remove()[source]

Do the necessary processing at the end.