1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-11-22 21:03:00 +00:00
kiwi-scp/src/kiwi-config.py

48 lines
1.1 KiB
Python
Raw Normal View History

2020-08-04 14:52:30 +00:00
#!/usr/bin/env python3
import logging
2020-08-06 11:43:45 +00:00
import kiwi
from kiwi.subcommands import *
2020-08-04 14:52:30 +00:00
2020-08-10 12:39:28 +00:00
def set_verbosity(logger, handler, verbosity):
if verbosity >= 2:
log_level = logging.DEBUG
log_format = "[%(asctime)s] %(levelname)s @ %(filename)s:%(funcName)s:%(lineno)d: %(message)s"
elif verbosity >= 1:
log_level = logging.INFO
log_format = "[%(asctime)s] %(levelname)s: %(message)s"
else:
log_level = logging.WARNING
log_format = "%(levelname)s: %(message)s"
logger.setLevel(log_level)
handler.setFormatter(logging.Formatter(log_format))
2020-08-10 12:39:28 +00:00
def main():
commands = [
InitCommand,
ShowCommand,
LogsCommand
]
for cmd in commands:
cmd.setup()
2020-08-10 13:21:39 +00:00
args = kiwi.Parser().get_args()
2020-08-10 12:39:28 +00:00
log_handler = logging.StreamHandler()
logging.getLogger().addHandler(log_handler)
2020-08-10 12:39:28 +00:00
set_verbosity(logging.getLogger(), log_handler, args.verbosity)
for cmd in commands:
if cmd.command == args.command:
cmd.run()
return
2020-08-04 14:52:30 +00:00
if __name__ == "__main__":
main()