45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
import logging
|
|
from pathlib import Path
|
|
|
|
import click
|
|
|
|
APP_NAME = 'iottb'
|
|
DB_NAME = 'iottb.db'
|
|
CFG_FILE_PATH = str(Path(click.get_app_dir(APP_NAME)).joinpath('iottb.cfg'))
|
|
CONSOLE_LOG_FORMATS = {
|
|
0: '%(levelname)s - %(message)s',
|
|
1: '%(levelname)s - %(module)s - %(message)s',
|
|
2: '%(levelname)s - %(module)s - %(funcName)s - %(lineno)d - %(message)s'
|
|
}
|
|
|
|
LOGFILE_LOG_FORMAT = {
|
|
0: '%(levelname)s - %(asctime)s - %(module)s - %(message)s',
|
|
1: '%(levelname)s - %(asctime)s - %(module)s - %(funcName)s - %(message)s',
|
|
2: '%(levelname)s - %(asctime)s - %(module)s - %(funcName)s - %(lineno)d - %(message)s'
|
|
}
|
|
MAX_VERBOSITY = len(CONSOLE_LOG_FORMATS) - 1
|
|
assert len(LOGFILE_LOG_FORMAT) == len(CONSOLE_LOG_FORMATS), 'Log formats must be same size'
|
|
|
|
LOGLEVEL = logging.DEBUG
|
|
LOGDIR = Path.cwd() / 'logs'
|
|
|
|
# Characters to just replace
|
|
REPLACEMENT_SET_CANONICAL_DEVICE_NAMES = {' ', '_', ',', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '=',
|
|
'{', '}', '[', ']',
|
|
'|',
|
|
'\\', ':', ';', '"', "'", '<', '>', '?', '/', '`', '~'}
|
|
# Characters to possibly error on
|
|
ERROR_SET_CANONICAL_DEVICE_NAMES = {',', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '=', '{', '}', '[', ']',
|
|
'|',
|
|
'\\', ':', ';', '"', "'", '<', '>', '?', '/', '`', '~'}
|
|
|
|
DEVICE_METADATA_FILE_NAME = 'device_metadata.json'
|
|
|
|
TB_ECHO_STYLES = {
|
|
'w': {'fg': 'yellow', 'bold': True},
|
|
'i': {'fg': 'blue', 'italic': True},
|
|
's': {'fg': 'green', 'bold': True},
|
|
'e': {'fg': 'red', 'bold': True},
|
|
'header': {'fg': 'bright_cyan', 'bold': True, 'italic': True}
|
|
}
|