python-mylib/mylib/scripts/pbar_test.py

42 lines
986 B
Python
Raw Permalink Normal View History

""" Test Progress bar """
import logging
import sys
import time
from mylib.pbar import Pbar
from mylib.scripts.helpers import get_opts_parser, init_logging
log = logging.getLogger("mylib.scripts.pbar_test")
2021-05-19 19:19:57 +02:00
def main(argv=None): # pylint: disable=too-many-locals,too-many-statements
"""Script main"""
if argv is None:
argv = sys.argv[1:]
# Options parser
default_max_val = 10
parser = get_opts_parser(progress=True)
parser.add_argument(
"-c",
"--count",
action="store",
type=int,
dest="count",
help=f"Progress bar max value (default: {default_max_val})",
default=default_max_val,
)
options = parser.parse_args()
# Initialize logs
init_logging(options, "Test Pbar")
pbar = Pbar("Test", options.count, enabled=options.progress)
for idx in range(0, options.count): # pylint: disable=unused-variable
pbar.increment()
time.sleep(0.3)
pbar.finish()