How to use the redislite.configuration function in redislite

To help you get started, we’ve selected a few redislite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yahoo / redislite / tests / test_configuration.py View on Github external
def test_configuration_modify_defaults(self):
        import redislite.configuration
        result = redislite.configuration.config(daemonize="no")
        self.assertIn('\ndaemonize no', result)

        # ensure the global defaults are not modified
        self.assertEquals(
            redislite.configuration.DEFAULT_REDIS_SETTINGS["daemonize"], "yes"
        )
github yahoo / redislite / redislite / client.py View on Github external
self.redis_configuration_filename = os.path.join(
            self.redis_dir, 'redis.config'
        )

        kwargs = dict(self.server_config)
        kwargs.update(
            {
                'pidfile': self.pidfile,
                'logfile': kwargs.get('logfile', self.logfile),
                'unixsocket': self.socket_file,
                'dbdir': self.dbdir,
                'dbfilename': self.dbfilename
            }
        )
        # Write a redis.config to our temp directory
        self.redis_configuration = configuration.config(**kwargs)
        with open(self.redis_configuration_filename, 'w') as file_handle:
            file_handle.write(self.redis_configuration)

        redis_executable = __redis_executable__
        if not redis_executable:  # pragma: no cover
            redis_executable = 'redis-server'
        command = [redis_executable, self.redis_configuration_filename]
        logger.debug('Running: %s', ' '.join(command))
        rc = subprocess.call(command)
        if rc:  # pragma: no cover
            logger.debug('The binary redis-server failed to start')
            redis_log = os.path.join(self.redis_dir, 'redis.log')
            if os.path.exists(redis_log):
                with open(redis_log) as file_handle:
                    logger.debug(file_handle.read())
            raise RedisLiteException('The binary redis-server failed to start')