<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# © 2011-2015 <NAME> <<EMAIL>>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import os
import sys
import math
import types
import gettext
import textwrap
import traceback
import ConfigParser
import curses.ascii
import unicodedata
from datetime import datetime
from oobjlib.connection import Connection
from oobjlib.component import Object
from functools import reduce

# Translation configuration
I18N_DIR = '%s/i18n/' % os.path.dirname(os.path.realpath(__file__))
I18N_DOMAIN = 'sentinel'
I18N_DEFAULT = 'en_US'

# _ will be initialized by gettext.install but prevent pep8 issues
_ = lambda a: a  # noqa

# Default configuration
DEFAULT_CONFIG = {
    'host': 'localhost',
    'user': 'admin',
    'password': '<PASSWORD>',
    'port': '8069',
    'test_file': None,
}

# Names of the ncurses colors
COLOR_NAMES = {
    'black': curses.COLOR_BLACK,
    'blue': curses.COLOR_BLUE,
    'cyan': curses.COLOR_CYAN,
    'green': curses.COLOR_GREEN,
    'magenta': curses.COLOR_MAGENTA,
    'red': curses.COLOR_RED,
    'white': curses.COLOR_WHITE,
    'yellow': curses.COLOR_YELLOW,
}

# Pre-defined color pairs
COLOR_PAIRS = {
    'base': (1, 'white', 'blue'),
    'info': (2, 'yellow', 'blue'),
    'error': (3, 'yellow', 'red'),
}


class Sentinel(object):

    """
    Sentinel class
    Manages scanner terminals
    """

    def __init__(self, stdscr):
        """
        Initialize the sentinel program
        """
        # Read user configuration
        config = ConfigParser.SafeConfigParser(DEFAULT_CONFIG)
        config.read('.oerp_sentinelrc')

        # No configfile found, exit
        if 'openerp' not in config.sections():
            raise Exception('Config Error', 'Config file not found !')

        # Connection to the OpenERP Server
        self.connection = Connection(
            server=config.get('openerp', 'host'),
            dbname=config.get('openerp', 'database'),
            login=config.get('openerp', 'user'),
            password=config.get('openerp', 'password'),
            port=config.get('openerp', 'port'),
        )<commit_msg>[IMP] Add .openerp_sentinelrc as name for the configuration file, to follow standard .openerp_serverrc name<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# © 2011-2015 <NAME> <<EMAIL>>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import os
import sys
import math
import types
import gettext
import textwrap
import traceback
import ConfigParser
import curses.ascii
import unicodedata
from datetime import datetime
from oobjlib.connection import Connection
from oobjlib.component import Object
from functools import reduce

# Translation configuration
I18N_DIR = '%s/i18n/' % os.path.dirname(os.path.realpath(__file__))
I18N_DOMAIN = 'sentinel'
I18N_DEFAULT = 'en_US'

# _ will be initialized by gettext.install but prevent pep8 issues
_ = lambda a: a  # noqa

# Default configuration
DEFAULT_CONFIG = {
    'host': 'localhost',
    'user': 'admin',
    'password': '<PASSWORD>',
    'port': '8069',
    'test_file': None,
}

# Names of the ncurses colors
COLOR_NAMES = {
    'black': curses.COLOR_BLACK,
    'blue': curses.COLOR_BLUE,
    'cyan': curses.COLOR_CYAN,
    'green': curses.COLOR_GREEN,
    'magenta': curses.COLOR_MAGENTA,
    'red': curses.COLOR_RED,
    'white': curses.COLOR_WHITE,
    'yellow': curses.COLOR_YELLOW,
}

# Pre-defined color pairs
COLOR_PAIRS = {
    'base': (1, 'white', 'blue'),
    'info': (2, 'yellow', 'blue'),
    'error': (3, 'yellow', 'red'),
}


class Sentinel(object):

    """
    Sentinel class
    Manages scanner terminals
    """

    def __init__(self, stdscr):
        """
        Initialize the sentinel program
        """
        # Read user configuration
        config = ConfigParser.SafeConfigParser(DEFAULT_CONFIG)
        config.read(['.oerp_sentinelrc', '.openerp_sentinelrc'])

        # No configfile found, exit
        if 'openerp' not in config.sections():
            raise Exception('Config Error', 'Config file not found !')

        # Connection to the OpenERP Server
        self.connection = Connection(
            server=config.get('openerp', 'host'),
            dbname=config.get('openerp', 'database'),
            login=config.get('openerp', 'user'),
            password=config.get('openerp', 'password'),
            port=config.get('openerp', 'port'),
        )
{'fraction_non_alphanumeric': 0.13337846987136087, 'fraction_numerical': 0.012186865267433988, 'mean_word_length': 3.2129277566539924, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3265236', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1407, 'n_words': 364}