Exemplo n.º 1
0
    def test_process_running(self):
        """Testing function process_running."""
        # Test running process
        current_processes = 'do_all_tests.py'
        result = sysinfo.process_running(current_processes)
        self.assertTrue(result)

        # Test running process
        result = sysinfo.process_running('{}'.format(random()))
        self.assertFalse(result)
Exemplo n.º 2
0
def check_lockfile():
    """Delete lockfile if found and ingester is not running.

    Args:
        None

    Returns:
        running: True if ingester script is running

    """
    # Initialize key variables
    agent_name = 'pattoo_ingester'
    config = Config()
    lockfile = shared_files.lock_file(agent_name, config)

    # Script running
    running = sysinfo.process_running(PATTOO_INGESTER_SCRIPT)

    # Delete lockfile if found and ingester is not running.
    # Caused by possible crash.
    if os.path.exists(lockfile) is True and running is False:
        os.remove(lockfile)
        log_message = ('''\
Lock file {} found, but the {} script is not running\
'''.format(lockfile, PATTOO_INGESTER_SCRIPT))
        log.log2warning(20030, log_message)

    return running