Skip to main content

Progress bar to watch file size

Project description

A class to show a progress bar of a certain file.
It will display progress up to 100%.

Example:
from Pbar import Pbar
myfile = Pbar(pfile="/tmp/somefile", size='25.9kb, timeout=20')
myfile.show_progress()

The above example will watch the file '/tmp/somefile' and display
the progress up to 25.9kb. If the file does not exist within 20
seconds then it will raise an exception.

Example (using fork to get the file):
from Pbar import Pbar
import os
url = 'http://www.someurl.com/path/to/somefile'
child = os.fork()
if child == 0:
os.system('wget %s -q -O /tmp/somefile' %url)
else:
myfile = Pbar(pfile='/tmp/somefile', size='120mb', timeout=10)
myfile.show_progress()

Required args: pfile, size
+ pfile:
String (path to file). The file to watch.
+ size:
String of number with denomination. (e.g. 100mb).
The expected total size of the file. e.g. '2gb'. (Valid sizes = b, kb, mb, gb).

Optional args: timeout, show_size_progress
+ timeout:
Integer. The timeout (in seconds) Pbar will wait for the file
to exist once show_progress() has been called. This
is useful if you are waiting for the file to get created.
The default is 5 seconds.
+ show_size_progress:
Boolean. Default is False. Setting this to true
will change the output from showing 'File: and Current size:'
to showing the 'current size of total size'. This way is not
best.

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

Pbar-1.0.tar.gz (2.2 kB view details)

Uploaded Source

File details

Details for the file Pbar-1.0.tar.gz.

File metadata

  • Download URL: Pbar-1.0.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Pbar-1.0.tar.gz
Algorithm Hash digest
SHA256 a77d5a966cb0aec9b02dfd717d3d289147852dbb10de4cdf5dd3af5ddf247bb5
MD5 b8ac8e0d10c93ad25c8fb43ef0834106
BLAKE2b-256 10f60367bb71ee5e6a435d56af90567c56c4a0294712db75c36e23b31be6ed88

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page