Skip to main content

Fast, Extensible Progress Meter (tqdm) For Django

Project description

PyPI-Status PyPI-Versions LICENSE Travis Codecov Requirements Status RequiDownloads

Fast, Extensible Progress Meter (tqdm) For Django.

Use tqdm in Django management commands seamlessly.
It provides simple universal commands for Django management command to output text using standard command functions and tqdm.
Currently supported versions of Django are supported.

Usage

from django_tqdm import BaseCommand
from time import sleep

class Command(BaseCommand):
    def handle(self, *args, **options):
        # Output directly
        self.error('Error')
        self.info('Info')

        # Output through tqdm
        t = self.tqdm(total=50)
        for x in range(50):
            sleep(0.03)
            t.update(1)

            if x == 10:
                t.info('X = 10')
            if x == 20:
                t.error('X = 20')

Advanced:

info(text, ending='\n', fatal=False)
error(text, ending='\n', fatal=False)
write(text, ending='\n', fatal=False, error=False)

If you set fatal to True it will terminate the command after printing the message.

For documentation on tqdm see tqdm.

Comparison

In django-tqdm:

self.info('info')
self.error('error')

In vanilla Django:

self.stdout.write('info')
self.stderr.write('error')

Demos

Demo 1 - Simple usage

self.info('info')
self.error('error')

Demo1

Demo 2 - tqdm usage

t = self.tqdm(total=50)
for x in range(50):
    sleep(0.02)
    t.update(1)
    if x == 10:
        t.info('info')
    if x == 40:
        t.error('error')

Demo2

Demo 3 - Vanilla tqdm with default settings for comparison

t = tqdm(total=50)
for x in range(50):
    sleep(0.02)
    t.update(1)
    if x == 25:
        t.write('info')
    if x == 40:
        t.write('error', file=sys.stderr)

Demo3

Development

Use clean.sh to automatically prettify your code.
Use tox for testing and linting.

Project details


Download files

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

Files for django-tqdm, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size django_tqdm-1.0.0-py3-none-any.whl (8.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django_tqdm-1.0.0.tar.gz (5.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page