<commit_before>#!/usr/bin/env python
"""
The main program that is the entry point for the SeedboxManager application.
Provides the ability to configure and start up processing.
"""
from __future__ import absolute_import
import logging
import os
import sys

import lockfile
from lockfile import pidlockfile
from oslo.config import cfg

from seedbox import db
from seedbox import logext as logmgr
from seedbox import options
from seedbox import process

LOG = logging.getLogger(__name__)


def main():
    """
    Entry point for seedmgr
    """

    # processes all command-line inputs that control how we execute
    # logging, run mode, etc.; and we get a handle back to access
    # the info
    options.initialize(sys.argv[1:])

    # configure our logging
    logmgr.configure()
    cfg.CONF.log_opt_values(LOG, logging.DEBUG)

    # need to create a lock to make sure multiple instances do not start at
    # the same time because we are running as a cron.
    filelock = os.path.join(cfg.CONF.config_dir, 'seedmgr.lock')
    lock = pidlockfile.PIDLockFile(filelock, timeout=10)
    try:
        with lock:

            # setup database and initialize connection
            db.dbapi(cfg.CONF)

            # time to start processing
            process.start()

    except lockfile.LockTimeout as lockerr:
        # if we have managed timeout, it means there is another instance
        # already running so we will simply bow out and let the existing
        # one still run.
        LOG.info('Already running; if not delete lock file: %s', lockerr)<commit_msg>clean up to further simplify implementation of pid lockfile<commit_after>#!/usr/bin/env python
"""
The main program that is the entry point for the SeedboxManager application.
Provides the ability to configure and start up processing.
"""
from __future__ import absolute_import
import logging
import os
import sys

import lockfile
from lockfile import pidlockfile
from oslo.config import cfg

from seedbox import db
from seedbox import logext as logmgr
from seedbox import options
from seedbox import process

LOG = logging.getLogger(__name__)


def main():
    """
    Entry point for seedmgr
    """

    # processes all command-line inputs that control how we execute
    # logging, run mode, etc.; and we get a handle back to access
    # the info
    options.initialize(sys.argv[1:])

    # configure our logging
    logmgr.configure()
    cfg.CONF.log_opt_values(LOG, logging.DEBUG)

    try:
        # need to create a lock to make sure multiple instances do not start
        # at the same time because we are running as a cron.
        with pidlockfile.PIDLockFile(os.path.join(cfg.CONF.config_dir,
                                     'seedmgr.lock'), timeout=10):

            # setup database and initialize connection
            db.dbapi(cfg.CONF)

            # time to start processing
            process.start()

    except lockfile.LockTimeout as lockerr:
        # if we have managed timeout, it means there is another instance
        # already running so we will simply bow out and let the existing
        # one still run.
        LOG.info('Already running; if not delete lock file: %s', lockerr)
{'fraction_non_alphanumeric': 0.06338249137119548, 'fraction_numerical': 0.0018826482585503608, 'mean_word_length': 2.8878048780487804, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6561522', 'n_tokens_mistral': 851, 'n_tokens_neox': 829, 'n_words': 367}