python-mylib/mylib/scripts/pbar_test.py
Benjamin Renard 62c3fadf96
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Introduce pyupgrade,isort,black and configure pre-commit hooks to run all testing tools before commit
2023-01-16 12:56:12 +01:00

41 lines
986 B
Python

""" 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")
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()