44 lines
1 KiB
Python
44 lines
1 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
""" Test Progress bar """
|
|
import logging
|
|
import time
|
|
import sys
|
|
|
|
from mylib.pbar import Pbar
|
|
from mylib.scripts.helpers import get_opts_parser
|
|
from mylib.scripts.helpers import 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()
|