Setting up the argument parser and the logger

This commit is contained in:
Zoe Roux
2020-11-06 21:36:26 +01:00
parent 0553984ac9
commit b7df556da3
6 changed files with 20 additions and 3 deletions
+3
View File
@@ -1 +1,4 @@
from .autopipe import Autopipe
from input import *
from output import *
from pipe import *
+11 -1
View File
@@ -1,5 +1,15 @@
#!/usr/bin/env python3
import autopipe
import logging
from argparse import ArgumentParser
if __name__ == "__main__":
autopipe.Autopipe()
parser = ArgumentParser(description="Easily run advanced pipelines in a daemon or in one run sessions.")
parser.add_argument("coordinator", help="The name of your pipeline coordinator.")
parser.add_argument("-v", "--verbose", choices=["debug", "info", "warn", "error"], nargs="?", const="info",
default="warn", dest="log_level", metavar="loglevel",
help="Set the logging level.", type=str.lower)
args = parser.parse_args()
autopipe.Autopipe(args.coordinator, log_level=getattr(logging, args.log_level.upper()))
+6 -2
View File
@@ -1,4 +1,8 @@
import logging
class Autopipe:
def __init__(self):
def __init__(self, coordinator, log_level=logging.WARNING):
logging.basicConfig(format="%(levelname)s: %(message)s", level=log_level)
print("Hello from autopipe")
pass
logging.info(f"Using coordinator: {coordinator}")
View File
View File
View File