Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Jitenshea package
Bicycle-sharing analysis
"""
import os
import logging
import configparser
import daiquiri
import daiquiri.formatter
FORMAT = '%(asctime)s :: %(color)s%(levelname)s :: %(name)s :: %(funcName)s : %(message)s%(color_stop)s'
daiquiri.setup(level=logging.INFO, outputs=(
daiquiri.output.Stream(formatter=daiquiri.formatter.ColorFormatter(
fmt=FORMAT)),
))
logger = daiquiri.getLogger("root")
_ROOT = os.path.dirname(os.path.abspath(__file__))
_CONFIG = os.getenv('JITENSHEA_CONFIG')
_CONFIG = _CONFIG if _CONFIG is not None else os.path.join(_ROOT, 'config.ini')
if not os.path.isfile(_CONFIG):
logger.error("Configuration file '%s' not found", _CONFIG)
config = None
else:
config = configparser.ConfigParser(allow_no_value=True)
with open(_CONFIG) as fobj:
import logging
import daiquiri
import daiquiri.formatter
daiquiri.setup(level=logging.INFO, outputs=(
daiquiri.output.Stream(formatter=daiquiri.formatter.ColorFormatter(
fmt="%(asctime)s [PID %(process)d] [%(levelname)s] "
"%(name)s -> %(message)s")),
))
logger = daiquiri.getLogger(__name__)
logger.info("It works with a custom format!")
import os
import daiquiri
__version__ = "0.6.3.post1"
# Do not log Tensorflow messages
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
# Configure the logger
daiquiri.setup(
level=logging.INFO,
outputs=(
daiquiri.output.Stream(
formatter=daiquiri.formatter.ColorFormatter(
fmt=(
"%(asctime)s :: %(levelname)s :: %(module)s :: "
"%(funcName)s : %(color)s%(message)s%(color_stop)s"
)
)
),
),
)
logger = daiquiri.getLogger("root")
# Deeposlandia supports feature detection (featdet) and semantic segmentation (semseg)
AVAILABLE_MODELS = ("featdet", "semseg")
# Configuration file handling
_DEEPOSL_CONFIG = os.getenv("DEEPOSL_CONFIG")
_DEEPOSL_CONFIG = (
def main(ctx, verbose=False, debug=False, log_file=None,
env_prefix=None, global_urls_variable=None):
formatter = daiquiri.formatter.ColorFormatter(
fmt="%(color)s%(levelname)s "
"[%(name)s] %(message)s%(color_stop)s")
outputs = [
daiquiri.output.Stream(sys.stderr, formatter=formatter)
]
if log_file:
outputs.append(daiquiri.output.File(log_file,
formatter=formatter))
ctx.obj = {
"debug": debug,
}
if env_prefix is not None:
ctx.obj['env_prefix'] = env_prefix
def setup_logging():
daiquiri.setup(
outputs=[daiquiri.output.Stream(
sys.stdout,
formatter=daiquiri.formatter.ColorFormatter(
"%(asctime)s [%(process)d] %(color)s%(levelname)-8.8s "
"%(name)s: %(message)s%(color_stop)s"),
)],
level=(logging.DEBUG if config.DEBUG else logging.INFO),
)
daiquiri.set_default_log_levels([
("rq", "ERROR"),
# ("github.Requester", "DEBUG"),
from IPython import get_ipython
daiquiri.setup(
level=logging.DEBUG,
outputs=[
daiquiri.output.File(
level=logging.DEBUG,
filename='.log',
formatter=daiquiri.formatter.ColorFormatter(
fmt="%(asctime)s [%(process)d] %(color)s%(levelname)-8.8s %(name)s:"
"%(lineno)d: [JupyterRequire] %(message)s%(color_stop)s"
)),
daiquiri.output.Stream(
level=logging.WARN,
formatter=daiquiri.formatter.ColorFormatter(
fmt="%(asctime)s [%(process)d] %(color)s%(levelname)-8.8s %(name)s:"
"%(lineno)d: [JupyterRequire] %(message)s%(color_stop)s"
)
),
],
)
logger = daiquiri.getLogger()
def load_ipython_extension(ipython):
"""Load the IPython Jupyter Require extension."""
from .magic import RequireJSMagic
logger.debug("Loading Jupyter Require extension.")
import logging
import daiquiri
import daiquiri.formatter
daiquiri.setup(level=logging.INFO, outputs=(
daiquiri.output.Stream(formatter=daiquiri.formatter.ColorFormatter(
fmt=(daiquiri.formatter.DEFAULT_FORMAT +
" [%(subsystem)s is %(mood)s]"))),
))
logger = daiquiri.getLogger(__name__, subsystem="example")
logger.info("It works and log to stderr by default with color!",
mood="happy")
def setup_logger(logger_dir, name="logger"):
os.environ['TZ'] = 'Africa/Johannesburg'
time.tzset()
daiquiri_formatter = daiquiri.formatter.ColorFormatter(
fmt= "%(asctime)s %(color)s%(levelname)s: %(message)s%(color_stop)s",
datefmt="%Y-%m-%d %H:%M:%S")
logger_path = os.path.join(logger_dir, name)
daiquiri.setup(level=logging.INFO, outputs=(
daiquiri.output.Stream(formatter=daiquiri_formatter),
daiquiri.output.File(logger_path,formatter=daiquiri_formatter),
))