Add argument parsing for development and verbose logging modes
This commit is contained in:
parent
a81d277f17
commit
503ffd0930
2 changed files with 17 additions and 6 deletions
23
main.py
23
main.py
|
|
@ -1,11 +1,11 @@
|
|||
import connectors
|
||||
import argparse
|
||||
import logging
|
||||
import config
|
||||
|
||||
logging.basicConfig(
|
||||
filename="log",
|
||||
filemode="w",
|
||||
level=logging.INFO,
|
||||
format="%(levelname)s - %(message)s",
|
||||
)
|
||||
|
||||
|
|
@ -198,10 +198,21 @@ if __name__ == "__main__":
|
|||
logging.getLogger("urllib3").setLevel(logging.WARNING)
|
||||
logging.getLogger("httpcore").setLevel(logging.WARNING)
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-d", "--dev", action="store_true")
|
||||
parser.add_argument("-v", "--verbose", action="store_true")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.dev:
|
||||
abs = connectors.ABSConnectorMock(config.ABS_API_URL, config.ABS_API_TOKEN)
|
||||
audible = connectors.AudibleConnectorMock(config.AUDIBLE_AUTH_FILE)
|
||||
audnexus = connectors.AudNexusConnectorMock()
|
||||
else:
|
||||
abs = connectors.ABSConnector(config.ABS_API_URL, config.ABS_API_TOKEN)
|
||||
audible = connectors.AudibleConnector(config.AUDIBLE_AUTH_FILE)
|
||||
audnexus = connectors.AudNexusConnector()
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
abs = connectors.ABSConnector(config.ABS_API_URL, config.ABS_API_TOKEN)
|
||||
audible = connectors.AudibleConnector(config.AUDIBLE_AUTH_FILE)
|
||||
audnexus = connectors.AudNexusConnector()
|
||||
|
||||
logger.setLevel(logging.DEBUG if args.verbose else logging.INFO)
|
||||
main()
|
||||
|
|
|
|||
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue