diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-10-19 13:23:05 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-10-19 13:23:05 +0200 |
commit | 42164da16c6ce187d1f5c19dc5083165d94da075 (patch) | |
tree | 38e36cf27e1adc155fbcde08e30f4666cfa577a7 | |
parent | 8b0770d7cfc8c696ef836717f97a72d6ff140556 (diff) |
example: make loglevel configurable from comandline
-rwxr-xr-x | example.py | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -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: |