summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-10-19 13:23:05 +0200
committerAnton Khirnov <anton@khirnov.net>2020-10-19 13:23:05 +0200
commit42164da16c6ce187d1f5c19dc5083165d94da075 (patch)
tree38e36cf27e1adc155fbcde08e30f4666cfa577a7
parent8b0770d7cfc8c696ef836717f97a72d6ff140556 (diff)
example: make loglevel configurable from comandline
-rwxr-xr-xexample.py16
1 files 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: