<commit_before># -*- coding: utf-8 -*-
#Copyright (C) 2009-2010 :
#    <NAME>, <EMAIL>
#    <NAME>, <EMAIL>
#    <NAME>, <EMAIL>
#    <NAME>, <EMAIL>
#
#This file is part of Shinken.
#
#Shinken is free software: you can redistribute it and/or modify
#it under the terms of the GNU Affero General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#Shinken is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU Affero General Public License for more details.
#
#You should have received a copy of the GNU Affero General Public License
#along with Shinken.  If not, see <http://www.gnu.org/licenses/>.

import os, errno, sys, time, signal, select, random 
import ConfigParser


import shinken.pyro_wrapper as pyro
from shinken.pyro_wrapper import InvalidWorkDir
Pyro = pyro.Pyro

from shinken.log import logger
from shinken.modulesmanager import ModulesManager
from shinken.util import to_int, to_bool


if os.name != 'nt':
    from pwd import getpwnam
    from grp import getgrnam


##########################   DAEMON PART    ###############################
# The standard I/O file descriptors are redirected to /dev/null by default.
REDIRECT_TO = getattr(os, "devnull", "/dev/null")

UMASK = 0
VERSION = "0.5"


class InvalidPidDir(Exception): pass



class Interface(object):
    """ Interface for pyro communications """
    
    def __init__(self, app):
        """ 'app´ is to be set to the owner of this interface. """

        self.pyro_obj = Pyro.core.ObjBase() 
        self.pyro_obj.delegateTo(self)
        
        self.app = app
        self.running_id = "%d.%d" % (time.time(), random.random())

    def ping(self):
        return "pong"

    def get_running_id(self):
        return self.running_id
    
    def put_conf(self, conf):
        self.app.new_conf = conf

    def wait_new_conf(self):
        self.app.cur_conf = None
        
    def have_conf(self):
        return self.app.cur_conf is not None




class Daemon:

    properties = {
        'workdir':      { 'default': '/usr/local/shinken/var', 'pythonize': None, 'path': True },
        'host':         { 'default': '0.0.0.0', 'pythonize': None },
        'user':         { 'default': 'shinken', 'pythonize': None },
        'group':        { 'default': 'shinken', 'pythonize': None },
        'use_ssl':      { 'default': '0', 'pythonize': to_bool },
        'certs_dir':    { 'default': 'etc/certs', 'pythonize': None },
        'ca_cert':      { 'default': 'etc/certs/ca.pem', 'pythonize': None },
        'server_cert':  { 'default': 'etc/certs/server.pem', 'pythonize': None },
        'use_local_log':{ 'default': '0', 'pythonize': to_bool },
        'hard_ssl_name_check':    { 'default': '0', 'pythonize': to_bool },
        'idontcareaboutsecurity': { 'default': '0', 'pythonize': to_bool },
        'spare':        { 'default': '0', 'pythonize': to_bool }
    }

    def __init__(self, name, config_file, is_daemon, do_replace, debug, debug_file):<commit_msg>fix: Daemon needs subclass object for super..<commit_after># -*- coding: utf-8 -*-
#Copyright (C) 2009-2010 :
#    <NAME>, nap<EMAIL>
#    <NAME>, <EMAIL>
#    <NAME>, <EMAIL>
#    <NAME>, <EMAIL>
#
#This file is part of Shinken.
#
#Shinken is free software: you can redistribute it and/or modify
#it under the terms of the GNU Affero General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#Shinken is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU Affero General Public License for more details.
#
#You should have received a copy of the GNU Affero General Public License
#along with Shinken.  If not, see <http://www.gnu.org/licenses/>.

import os, errno, sys, time, signal, select, random 
import ConfigParser


import shinken.pyro_wrapper as pyro
from shinken.pyro_wrapper import InvalidWorkDir
Pyro = pyro.Pyro

from shinken.log import logger
from shinken.modulesmanager import ModulesManager
from shinken.util import to_int, to_bool


if os.name != 'nt':
    from pwd import getpwnam
    from grp import getgrnam


##########################   DAEMON PART    ###############################
# The standard I/O file descriptors are redirected to /dev/null by default.
REDIRECT_TO = getattr(os, "devnull", "/dev/null")

UMASK = 0
VERSION = "0.5"


class InvalidPidDir(Exception): pass



class Interface(object):
    """ Interface for pyro communications """
    
    def __init__(self, app):
        """ 'app´ is to be set to the owner of this interface. """

        self.pyro_obj = Pyro.core.ObjBase() 
        self.pyro_obj.delegateTo(self)
        
        self.app = app
        self.running_id = "%d.%d" % (time.time(), random.random())

    def ping(self):
        return "pong"

    def get_running_id(self):
        return self.running_id
    
    def put_conf(self, conf):
        self.app.new_conf = conf

    def wait_new_conf(self):
        self.app.cur_conf = None
        
    def have_conf(self):
        return self.app.cur_conf is not None




class Daemon(object):

    properties = {
        'workdir':      { 'default': '/usr/local/shinken/var', 'pythonize': None, 'path': True },
        'host':         { 'default': '0.0.0.0', 'pythonize': None },
        'user':         { 'default': 'shinken', 'pythonize': None },
        'group':        { 'default': 'shinken', 'pythonize': None },
        'use_ssl':      { 'default': '0', 'pythonize': to_bool },
        'certs_dir':    { 'default': 'etc/certs', 'pythonize': None },
        'ca_cert':      { 'default': 'etc/certs/ca.pem', 'pythonize': None },
        'server_cert':  { 'default': 'etc/certs/server.pem', 'pythonize': None },
        'use_local_log':{ 'default': '0', 'pythonize': to_bool },
        'hard_ssl_name_check':    { 'default': '0', 'pythonize': to_bool },
        'idontcareaboutsecurity': { 'default': '0', 'pythonize': to_bool },
        'spare':        { 'default': '0', 'pythonize': to_bool }
    }

    def __init__(self, name, config_file, is_daemon, do_replace, debug, debug_file):
{'fraction_non_alphanumeric': 0.14796798995763377, 'fraction_numerical': 0.006904126784873686, 'mean_word_length': 3.057288351368555, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, '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': '462554', 'n_tokens_mistral': 2086, 'n_tokens_neox': 2012, 'n_words': 631}