예제 #1
0
    def __init__(self, ccnet_dir, args, events_listener_enabled=True, background_tasks_enabled=True):
        self._ccnet_dir = ccnet_dir
        self._central_config_dir = os.environ.get('SEAFILE_CENTRAL_CONF_DIR')
        self._args = args
        self._events_listener_enabled = events_listener_enabled
        self._bg_tasks_enabled = background_tasks_enabled
        try:
            load_config(args.config_file)
        except Exception as e:
            logging.error('Error loading seafevents config. Detial: %s' % e)
            raise RuntimeError("Error loading seafevents config. Detial: %s" % e)

        self._events_listener = None
        if self._events_listener_enabled:
            self._events_listener = EventsMQListener(self._args.config_file)

        if appconfig.publish_enabled:
            events_publisher.init()
        else:
            logging.info("Events publish to redis is disabled.")

        self._bg_tasks = None
        if self._bg_tasks_enabled:
            self._bg_tasks = BackgroundTasks(args.config_file)

        if appconfig.enable_statistics:
            self.update_login_record_task = CountUserActivity()
            self.count_traffic_task = CountTrafficInfo()

        self._ccnet_session = None
        self._sync_client = None

        self._evbase = libevent.Base() #pylint: disable=E1101
        self._sighandler = SignalHandler(self._evbase)
예제 #2
0
    def __init__(self,
                 args,
                 events_handler_enabled=True,
                 background_tasks_enabled=True):
        self._central_config_dir = os.environ.get('SEAFILE_CENTRAL_CONF_DIR')
        self._args = args
        self._events_handler_enabled = events_handler_enabled
        self._bg_tasks_enabled = background_tasks_enabled
        try:
            load_config(args.config_file)
        except Exception as e:
            logging.error('Error loading seafevents config. Detail: %s' % e)
            raise RuntimeError("Error loading seafevents config. Detail: %s" %
                               e)

        self._events_handler = None
        if self._events_handler_enabled:
            self._events_handler = EventsHandler(self._args.config_file)

        if appconfig.publish_enabled:
            events_publisher.init()
        else:
            logging.info("Events publish to redis is disabled.")

        self._bg_tasks = None
        if self._bg_tasks_enabled:
            self._bg_tasks = BackgroundTasks(args.config_file)

        if appconfig.enable_statistics:
            self.update_login_record_task = CountUserActivity()
            self.count_traffic_task = CountTrafficInfo()
예제 #3
0
    def __init__(self, ccnet_dir, args, events_listener_enabled=True):
        self._ccnet_dir = ccnet_dir
        self._central_config_dir = os.environ.get('SEAFILE_CENTRAL_CONF_DIR')
        self._args = args
        self._events_listener_enabled = events_listener_enabled
        try:
            load_config(args.config_file)
        except Exception as e:
            logging.error('Error loading seafevents config. Detial: %s' % e)
            raise RuntimeError("Error loading seafevents config. Detial: %s" %
                               e)

        self._events_listener = None
        if self._events_listener_enabled:
            self._events_listener = EventsMQListener(self._args.config_file)

        self._ccnet_session = None
        self._sync_client = None

        self._evbase = libevent.Base()  #pylint: disable=E1101
        self._sighandler = SignalHandler(self._evbase)
예제 #4
0
    def __init__(self):
        self._parser = argparse.ArgumentParser(
            description='seafevents main program')
        self._parser.add_argument('--config-file',
                                  default=os.path.join(os.getcwd(),
                                                       'events.conf'),
                                  help='seafevents config file')
        args = self._parser.parse_args()
        kw = {
            'format': '[%(asctime)s] [%(levelname)s] %(message)s',
            'datefmt': '%m/%d/%Y %H:%M:%S',
            'level': 0,
            'stream': sys.stdout
        }
        logging.basicConfig(**kw)
        # basicconfig didn't work
        logging.getLogger().setLevel(logging.INFO)

        load_config(args.config_file)
        self._db_session_class = appconfig.event_session
        self._history_repo = self.get_repo_and_last_time()
        self._current_repo_position = 0
        self._current_commit_position = 0
예제 #5
0
from seafevents.virus_scanner.scan_settings import Settings
from seafevents.virus_scanner.virus_scan import VirusScan

from seafevents.app.config import load_config

if __name__ == "__main__":
    kw = {
        'format': '[%(asctime)s] [%(levelname)s] %(message)s',
        'datefmt': '%m/%d/%Y %H:%M:%S',
        'level': logging.DEBUG,
        'stream': sys.stdout
    }
    logging.basicConfig(**kw)

    from seafevents.virus_scanner.scan_settings import logger
    logger.setLevel(logging.DEBUG)

    parser = argparse.ArgumentParser()
    parser.add_argument('-c', '--config-file',
                        default=os.path.join(os.path.abspath('..'), 'events.conf'),
                        help='seafevents config file')
    args = parser.parse_args()

    load_config(args.config_file)

    setting = Settings(args.config_file)
    if setting.is_enabled():
        VirusScan(setting).start()
    else:
        logger.info('Virus scan is disabled.')
예제 #6
0
def init(config_file):
    if not appconfig.get('session_cls'):
        load_config(config_file)