Giter Site home page Giter Site logo

Comments (4)

wolph avatar wolph commented on September 28, 2024

Sorry about that... looks like something went wrong there. I created a cli command for easy commandline usage similar to pv but I totally forgot to finish it. I'll remove the command for now and re-add it once it's fully working.

from python-progressbar.

medkrimi avatar medkrimi commented on September 28, 2024

Facing the same issue, any update ?

from python-progressbar.

wolph avatar wolph commented on September 28, 2024

I'm working on a command that can be used as a drop-in replacement for the pv (pipeview) command with better output and some extra intelligence. A sneak preview of what it should roughly handle (if possible):

import argparse
import contextlib
import pathlib
import sys
import time

import progressbar


def create_pv_parser() -> argparse.ArgumentParser:
    parser = argparse.ArgumentParser(
        description='Monitor the progress of data through a pipe.')

    # Display switches
    parser.add_argument('-p', '--progress', action='store_true',
                        help='Turn the progress bar on.')
    parser.add_argument('-t', '--timer', action='store_true',
                        help='Turn the timer on.')
    parser.add_argument('-e', '--eta', action='store_true',
                        help='Turn the ETA timer on.')
    parser.add_argument('-I', '--fineta', action='store_true',
                        help='Display the ETA as local time of arrival.')
    parser.add_argument('-r', '--rate', action='store_true',
                        help='Turn the rate counter on.')
    parser.add_argument('-a', '--average-rate', action='store_true',
                        help='Turn the average rate counter on.')
    parser.add_argument('-b', '--bytes', action='store_true',
                        help='Turn the total byte counter on.')
    parser.add_argument('-8', '--bits', action='store_true',
                        help='Display total bits instead of bytes.')
    parser.add_argument('-T', '--buffer-percent', action='store_true',
                        help='Turn on the transfer buffer percentage display.')
    parser.add_argument('-A', '--last-written', type=int,
                        help='Show the last NUM bytes written.')
    parser.add_argument('-F', '--format', type=str,
                        help='Use the format string FORMAT for output format.')
    parser.add_argument('-n', '--numeric', action='store_true',
                        help='Numeric output.')
    parser.add_argument('-q', '--quiet', action='store_true', help='No output.')

    # Output modifiers
    parser.add_argument('-W', '--wait', action='store_true',
                        help='Wait until the first byte has been transferred.')
    parser.add_argument('-D', '--delay-start', type=float, help='Delay start.')
    parser.add_argument('-s', '--size', type=str,
                        help='Assume total data size is SIZE.')
    parser.add_argument('-l', '--line-mode', action='store_true',
                        help='Count lines instead of bytes.')
    parser.add_argument('-0', '--null', action='store_true',
                        help='Count lines terminated with a zero byte.')
    parser.add_argument('-i', '--interval', type=float,
                        help='Interval between updates.')
    parser.add_argument('-m', '--average-rate-window', type=int,
                        help='Window for average rate calculation.')
    parser.add_argument('-w', '--width', type=int,
                        help='Assume terminal is WIDTH characters wide.')
    parser.add_argument('-H', '--height', type=int,
                        help='Assume terminal is HEIGHT rows high.')
    parser.add_argument('-N', '--name', type=str,
                        help='Prefix output information with NAME.')
    parser.add_argument('-f', '--force', action='store_true',
                        help='Force output.')
    parser.add_argument('-c', '--cursor', action='store_true',
                        help='Use cursor positioning escape sequences.')

    # Data transfer modifiers
    parser.add_argument('-L', '--rate-limit', type=str,
                        help='Limit transfer to RATE bytes per second.')
    parser.add_argument('-B', '--buffer-size', type=str,
                        help='Use transfer buffer size of BYTES.')
    parser.add_argument('-C', '--no-splice', action='store_true',
                        help='Never use splice.')
    parser.add_argument('-E', '--skip-errors', action='store_true',
                        help='Ignore read errors.')
    parser.add_argument('-Z', '--error-skip-block', type=str,
                        help='Skip block size when ignoring errors.')
    parser.add_argument('-S', '--stop-at-size', action='store_true',
                        help='Stop transferring after SIZE bytes.')
    parser.add_argument('-Y', '--sync', action='store_true',
                        help='Synchronise buffer caches to disk after writes.')
    parser.add_argument('-K', '--direct-io', action='store_true',
                        help='Set O_DIRECT flag on all inputs/outputs.')
    parser.add_argument('-X', '--discard', action='store_true',
                        help='Discard input data instead of transferring it.')
    parser.add_argument('-d', '--watchfd', type=str,
                        help='Watch file descriptor of process.')
    parser.add_argument('-R', '--remote', type=int,
                        help='Remote control another running instance of pv.')

    # General options
    parser.add_argument('-P', '--pidfile', type=pathlib.Path,
                        help='Save process ID in FILE.')
    parser.add_argument(
        'input',
        help='Input file path. Uses stdin if not specified.',
        default='-',
        nargs='*',
    )
    parser.add_argument(
        '-o',
        '--output',
        default='-',
        help='Output file path. Uses stdout if not specified.')

    return parser

It won't be long, I promise :)

from python-progressbar.

wolph avatar wolph commented on September 28, 2024

I've created a new release with a progressbar command that can be used as a drop-in replacement for pv or to replace cat as an automatic progressbar.

It can be used like this:

progressbar /dev/zero > /dev/zero

Or like this:

cat /dev/zero | progressbar > /dev/zero

If the filesize is available it will show a progressbar, if not, it will show a spinner like the regular progressbar would

from python-progressbar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.