# Path: dlstats/version.py
# VERSION = (0, 8, 6)
# def version_str():
# 
# Path: dlstats/constants.py
# CACHE_URL = os.environ.get('WIDUKIND_CACHE_URL', 'simple') #redis://localhost:6379/0


import atexit
import tempfile
import pprint
import os
import sys
import contextlib
import gridfs
import click
            import requests_cache
from widukind_common.utils import get_mongo_url, get_mongo_client, configure_logging
from widukind_common.mongolock import MongoLock, MongoLockLocked
from widukind_common import errors
from dlstats import version
from dlstats.constants import CACHE_URL
            from widukind_common import debug
        from logging import FileHandler
        from dlstats import cache
        
        self.client_mongo = None
        self.db_mongo = None
        self.client_es = None
        self.fs_mongo = None
        
        self.logger = configure_logging(debug=self.debug, 
                                config_file=self.log_config, 
                                level=self.log_level)
        
        if self.log_file:
            self._set_log_file()
            
        if self.cache_enable:
            self._set_cache()
            
        if self.requests_cache_enable:
            self._set_requests_cache()
            
        if self.trace:
            debug.TRACE_ENABLE = True
            atexit.register(debug.flush_logs)

    def _set_log_file(self):
        handler = FileHandler(filename=self.log_file)
        if self.logger.hasHandlers():
            handler.setFormatter(self.logger.handlers[0].formatter)
        self.logger.addHandler(handler)
        
    def _set_cache(self):

# Path: dlstats/version.py
# VERSION = (0, 8, 6)
# def version_str():
# 
# Path: dlstats/constants.py
# CACHE_URL = os.environ.get('WIDUKIND_CACHE_URL', 'simple') #redis://localhost:6379/0


# Path: dlstats/client.py
import atexit
import tempfile
import pprint
import os
import sys
import contextlib
import gridfs
import click
            import requests_cache
from widukind_common.utils import get_mongo_url, get_mongo_client, configure_logging
from widukind_common.mongolock import MongoLock, MongoLockLocked
from widukind_common import errors
from dlstats import version
from dlstats.constants import CACHE_URL
            from widukind_common import debug
        from logging import FileHandler
        from dlstats import cache

        
        self.client_mongo = None
        self.db_mongo = None
        self.client_es = None
        self.fs_mongo = None
        
        self.logger = configure_logging(debug=self.debug, 
                                config_file=self.log_config, 
                                level=self.log_level)
        
        if self.log_file:
            self._set_log_file()
            
        if self.cache_enable:
            self._set_cache()
            
        if self.requests_cache_enable:
            self._set_requests_cache()
            
        if self.trace:
            debug.TRACE_ENABLE = True
            atexit.register(debug.flush_logs)

    def _set_log_file(self):
        handler = FileHandler(filename=self.log_file)
        if self.logger.hasHandlers():
            handler.setFormatter(self.logger.handlers[0].formatter)
        self.logger.addHandler(handler)
        
    def _set_cache(self):

        cache.configure_cache(cache_url=CACHE_URL)