From 42164da16c6ce187d1f5c19dc5083165d94da075 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 19 Oct 2020 13:23:05 +0200 Subject: example: make loglevel configurable from comandline --- example.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/example.py b/example.py index 62e237f..39e34cc 100755 --- a/example.py +++ b/example.py @@ -8,11 +8,6 @@ from lbup.repository import Repo from lbup.ssh_remote import SSHRemote from lbup.targets import TargetLocal, TargetSSH, TargetSSHLXCLVM -# define the backup targets -tgts = ( - #TargetLocal('local', dirs = ['/usr/local/share']), -) - def list_targets(tgts): for tgt in tgts: sys.stdout.write('%s\n %s\n' % (tgt.name, str(tgt))) @@ -21,15 +16,22 @@ def list_targets(tgts): parser = argparse.ArgumentParser() parser.add_argument('-l', '--list-targets', action = 'store_true') parser.add_argument('-n', '--dry-run', action = 'store_true') +parser.add_argument('-v', '--verbose', action = 'count', default = 0) parser.add_argument('targets', nargs = argparse.REMAINDER) args = parser.parse_args() +# configure logging +logging.basicConfig(level = max(3 - args.verbose, 0) * 10) +# define the backup targets +tgts = ( + #TargetLocal('local', dirs = ['/usr/local/share']), +) + + if args.list_targets: list_targets(tgts) sys.exit(0) -logging.basicConfig(level = logging.INFO) - if len(args.targets) > 0: tgts_run = [] for requested in args.targets: -- cgit v1.2.3