Пример #1
0
def syslog_handlers(logger_name,
                    address=('127.0.0.1', 514),
                    facility=0,
                    level='DEBUG'):
    global _root_logger_name, root_logger, _stdout
    logger_names = []
    loggers = []
    if type(logger_name) in [str]:
        logger_names = [logger_name]
    elif type(logger_name) in [list, tuple]:
        logger_names = logger_name
    else:
        return loggers
    for name in logger_names:
        logger = _getLogger(name)
        _level = logger_filters.get(name) or level
        _level = _level.upper()
        if _level == 'OFF':
            handler = NullHandler()
            logger.addHandler(handler)
        elif _level in ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']:
            del logger.handlers[:]
            logger.setLevel(_level)
            handler = SysLogHandler(address=tuple(address),
                                    facility=SysLogHandler.LOG_LOCAL0 +
                                    facility)
            handler.setLevel(_level)
            logger.addHandler(handler)
            if _stdout:
                handler = StdoutHandler()
                handler.setLevel(_level)
                logger.addHandler(handler)
        logger.propagate = 0
        if name == _root_logger_name:
            root_logger = logger
        loggers.append(logger)
    return loggers
Пример #2
0
    from ui_background_generator_dialog import Ui_BackgroundGeneratorDialog
except ImportError:
    from .ui_background_generator_dialog import Ui_BackgroundGeneratorDialog

import cv2

# Log file setting.
# import logging
# logging.basicConfig(filename='MainWindow.log', level=logging.DEBUG)

# Log output setting.
# If handler = StreamHandler(), log will output into StandardOutput.
from logging import getLogger, NullHandler, StreamHandler, DEBUG
logger = getLogger(__name__)
handler = NullHandler() if True else StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
logger.addHandler(handler)


def cvMatToQImage(im_in):
    logger.debug('Input image type: {0}'.format(im_in.dtype))
    if len(im_in.shape) is 3:
        height, width, bytesPerComponent = im_in.shape
        bytesPerLine = bytesPerComponent * width
        im_dst = cv2.cvtColor(im_in, cv2.COLOR_BGR2RGB)
        return QImage(im_dst.data, width, height, bytesPerLine,
                      QImage.Format_RGB888)
    else:
        height, width = im_in.shape
        return QImage(im_in.data, width, height, width, QImage.Format_Indexed8)
Пример #3
0
    from ui_js_plot_dialog import Ui_JSPlotDialog
except ImportError:
    from .ui_js_plot_dialog import Ui_JSPlotDialog

import cv2

# Log file setting.
# import logging
# logging.basicConfig(filename='MainWindow.log', level=logging.DEBUG)

# Log output setting.
# If handler = StreamHandler(), log will output into StandardOutput.
from logging import getLogger, NullHandler, StreamHandler, DEBUG
logger = getLogger(__name__)
handler = NullHandler() if True else StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
logger.addHandler(handler)

# determine if application is a script file or frozen exe
if getattr(sys, 'frozen', False):
    current_dir_path = sys._MEIPASS
    print(current_dir_path)
    if os.name == 'nt':
        import win32api

        win32api.SetDllDirectory(sys._MEIPASS)
elif __file__:
    current_dir_path = os.getcwd()

import urllib.request
Пример #4
0
import logging
from logging import NullHandler
from snueue.config.base import *

DEBUG = True
ASSETS_DEBUG = True

COMPASS_CONFIG = {'sourcemap': 'true'}

SECRET_KEY = get_secret('SNUEUE_SECRET_KEY')

# Optional host to be passed into app.run. Useful for running in docker
# so app can run with the host as 0.0.0.0 and be accessible from the host.
# Defaults to 127.0.0.1 (localhost)
HOST = get_secret('SNUEUE_HOST', False)

REDIS_HOST = get_secret('SNUEUE_DATABASE_HOST', False) or "localhost"

# Reddit API settings
REDDIT_USER_AGENT = get_secret('SNUEUE_REDDIT_USER_AGENT')
REDDIT_CLIENT_ID = get_secret('SNUEUE_REDDIT_CLIENT_ID')
REDDIT_CLIENT_SECRET = get_secret('SNUEUE_REDDIT_CLIENT_SECRET')

# Logging
# Use a no-op logger for developmenet since logs are printed by the
# debug server automatically.
LOGGING_LEVEL = logging.DEBUG
null_handler = NullHandler()
null_handler.setLevel(LOGGING_LEVEL)
LOGGING_HANDLER = null_handler
Пример #5
0
import logging
from logging import NullHandler
from snueue.config.base import *

DEBUG = True
ASSETS_DEBUG = True

COMPASS_CONFIG = {'sourcemap': 'true'}

SECRET_KEY = get_secret('SNUEUE_SECRET_KEY')

# Optional host to be passed into app.run. Useful for running in docker 
# so app can run with the host as 0.0.0.0 and be accessible from the host.
# Defaults to 127.0.0.1 (localhost)
HOST = get_secret('SNUEUE_HOST', False)

REDIS_HOST = get_secret('SNUEUE_DATABASE_HOST', False) or "localhost"

# Reddit API settings
REDDIT_USER_AGENT = get_secret('SNUEUE_REDDIT_USER_AGENT')
REDDIT_CLIENT_ID = get_secret('SNUEUE_REDDIT_CLIENT_ID')
REDDIT_CLIENT_SECRET = get_secret('SNUEUE_REDDIT_CLIENT_SECRET')

# Logging
# Use a no-op logger for developmenet since logs are printed by the
# debug server automatically.
LOGGING_LEVEL = logging.DEBUG
null_handler = NullHandler()
null_handler.setLevel(LOGGING_LEVEL)
LOGGING_HANDLER = null_handler