示例#1
0
    def parse_config(self, config_file):
        """parse config file and do basic sanity tests"""
        WesConfig.parse_config(self, config_file)

        # Sanity check config file
        # Check that all sections exist
        missing = {'daemon', 'seed_source', 'stream_source', 'drbg'} - \
                  set(self.config.sections())

        if len(missing) > 0:
            raise WesEntropyException(
                "Error parsing config file, missing required section(s) %s." %
                ", ".join(str(tmp) for tmp in missing))

        # Check that [daemon] contains required information
        missing = {'socket_path'} - \
                  set(self.config.options('daemon'))

        if len(missing) > 0:
            raise WesEntropyException(
                "Error parsing config file, missing required value(s) "
                "%s, in [conneciton]." %
                ", ".join(str(tmp) for tmp in missing))

        # Check that [stream_source] has at least one value, and that it's valid
        if len(self.config.options('stream_source')) < 1:
            raise WesEntropyException(
                "Error parsing config file, [stream_source] must have at "
                "least one option configured.")

        # Check that [seed_source] has at least one value, and that it's valid
        if len(self.config.options('seed_source')) < 1:
            raise WesEntropyException(
                "Error parsing config file, [seed_source] must have at "
                "least one option configured.")
示例#2
0
    def __init__(self, config, server):
        if server:
            self.default_config_file = '/etc/wesentropy/server.conf'
        else:
            self.default_config_file = '/etc/wesentropy/client.conf'

        WesConfig.__init__(self, config, self.default_config_file)

        self.working_dir = self.config.get('DEFAULT', 'working_dir')

        self.socket_path = self.config.get('daemon', 'socket_path')

        self.seed_source = ast.literal_eval(
            self.config.get('seed_source',
                            self.config.options('seed_source')[0]))

        self.stream_source = ast.literal_eval(
            self.config.get('stream_source',
                            self.config.options('stream_source')[0]))

        self.drbg_spec = self.config.get('drbg', 'drbg_spec')
        self.reseed_rate = self.config.get('drbg', 'reseed_rate')
示例#3
0
 def __init__(self, config):
     WesConfig.__init__(self, config, WesClientConfig.default_config_file)
     self.socket_path = self.config.get("daemon", "socket_path")