Ensure the host configuration file exists
342443
def host_config(self):
        
        if platform.system() == 'Darwin':
            default_file_dir = join(expanduser('~'),
                                    'vent_files')
        else:
            default_file_dir = '/opt/vent_files'
        status = self.ensure_dir(default_file_dir)
        if not isfile(self.cfg_file):
            config = Template(template=self.cfg_file)
            sections = {'main': {'files': default_file_dir},
                        'network-mapping': {},
                        'nvidia-docker-plugin': {'port': '3476'}}
            for s in sections:
                if sections[s]:
                    for option in sections[s]:
                        config.add_option(s, option, sections[s][option])
                else:
                    config.add_section(s)
            config.write_config()
        return status
972494
def _do(name, fun, path=None):
    '''
    
    '''
    host = find_guest(name, quiet=True, path=path)
    if not host:
        return False

    client = salt.client.get_local_client(__opts__['conf_file'])
    cmd_ret = client.cmd_iter(
            host,
            'lxc.{0}'.format(fun),
            [name],
            kwarg={'path': path},
            timeout=60)
    data = next(cmd_ret)
    data = data.get(host, {}).get('ret', None)
    if data:
        data = {host: data}
    return data
1201849
def associate_hosting_device_with_config_agent(
            self, client, config_agent_id, body):
        """"""
        return client.post((ConfigAgentHandlingHostingDevice.resource_path +
                            CFG_AGENT_HOSTING_DEVICES) % config_agent_id,
                           body=body)
939384
def check_configuration(ctx, base_key, needed_keys):
    

    # check for valid configuration
    if base_key not in ctx.keys():
        exit("[{}ERROR{}] missing configuration for '{}'"
             .format(ERROR_COLOR, RESET_COLOR, base_key))
        # TODO: offer to create configuration file
    if ctx.releaser is None:
        exit("[{}ERROR{}] empty configuration for '{}' found"
             .format(ERROR_COLOR, RESET_COLOR, base_key))
        # TODO: offer to create configuration file

    # TODO: allow use of default values
    for my_key in needed_keys:
        if my_key not in ctx[base_key].keys():
            exit("[{}ERROR{}] missing configuration key '{}.{}'"
                 .format(ERROR_COLOR, RESET_COLOR, base_key, my_key))
578388
def check
      raise Errors::ConfigurationInvalid, config.errors.join("; ") unless config.valid?
      distribution.check
    end
663389
def validate_config(self, config):
        

        try:
            hosts = config['hosts']
        except KeyError:
            raise InvalidConfigurationError('hosts', "",
                                            reason=('hosts configuration '
                                                    'section is required'))

        for key in config.keys():
            if key not in default_allowed_keys:
                raise InvalidConfigurationError(key, config[key])

        bucket = False
        # optional configuration
        try:
            for key in config['aws'].keys():
                if key == 'bucket' and config['aws'][key] is not None:
                    bucket = True
                if key not in aws_allowed_keys:
                    raise InvalidConfigurationError(key, config['aws'][key])
        except KeyError:
            pass

        # optional configuration
        try:
            for key in config['logging'].keys():
                if key not in logging_allowed_keys:
                    raise InvalidConfigurationError(key, config['logging'][key])
        except KeyError:
            pass

        # optional configuration
        try:
            for key in config['repository'].keys():
                if key not in repository_allowed_keys:
                    raise InvalidConfigurationError(key, config['repository'][key])
        except KeyError:
            pass

        # required configuration
        if type(config['hosts']) is not list:
            raise InvalidConfigurationError('hosts', config['hosts'],
                                            reason="hosts must be a list")
        filename = False
        for host in config['hosts']:
            for key in host.keys():
                if key == 'filename' and host['filename'] is not None:
                    filename = True
                if key == 'jump_host' and host['jump_host'] is not None:
                    for jump_key in host['jump_host'].keys():
                        if jump_key not in jump_host_allowed_keys:
                            raise InvalidConfigurationError(key, host['jump_host'])
                if key not in host_allowed_keys:
                    raise InvalidConfigurationError(key, host[key])

        if bucket and filename:
            raise InvalidConfigurationError('bucket', config['aws']['bucket'],
                                            reason=('bucket configuration is'
                                                    'incompatible with filename'
                                                    'configuration in hosts'))
1197293
def _assert_dirs_exist(self, setting_name):
        
        v = self._get_setting(setting_name)
        if (not os.path.isdir(os.path.split(v)[0])) or os.path.isdir(v):
            self.raise_config_error(
                setting_name,
                v,
                str,
                'a file path in an existing directory',
                is_none_allowed=False,
            )
961902
def ensure_exists(self):
        """"""
        if not self.context.is_directory(self.directory):
            # This can also happen when we don't have permission to one of the
            # parent directories so we'll point that out in the error message
            # when it seems applicable (so as not to confuse users).
            if self.context.have_superuser_privileges:
                msg = "The directory %s doesn't exist!"
                raise ValueError(msg % self)
            else:
                raise ValueError(compact("""
                    The directory {location} isn't accessible, most likely
                    because it doesn't exist or because of permissions. If
                    you're sure the directory exists you can use the
                    --use-sudo option.
                """, location=self))
1030065
private function config_host(string $host=null) {
		if (filter_var($host, FILTER_VALIDATE_URL,
				FILTER_FLAG_PATH_REQUIRED) === false)
			return;
		$host = rtrim($host, '/') . '/';
		$home = $this->home;
		if ($home == '/') {
			$this->host = $host;
			return;
		}
		# home must be at the end of host
		if (substr($host, -strlen($home)) != $home)
			return;
		$this->host = $host;
	}
813501
def exists(provider, config_location=DEFAULT_CONFIG_DIR):
    

    config_dir = os.path.join(config_location, NOIPY_CONFIG)
    auth_file = os.path.join(config_dir, provider)
    return os.path.exists(auth_file)
162969
def ensure_configuration_file
      config = @options[:config_paths]
      return true if File.exists?(config) && File.readable?(config)
      puts "Could not find the asset configuration file \"#{config}\""
      exit(1)
    end
769630
def _verifyHostKey(self, hostKey, fingerprint):
        
        if fingerprint in self.knownHosts:
            return defer.succeed(True)
        return defer.fail(UnknownHostKey(hostKey, fingerprint))
396322
def validate_configuration!
      unless @host.is_a?(String) && @host.length > 0
        raise(Error::ConfigurationError, "Invalid host specified: Host must contain the host to redirect to.")
      end
      if @host.end_with?('/')
        raise(Error::ConfigurationError, "Invalid host specified: #{@host} should not end with a trailing slash.")
      end

      unless @path.is_a?(String) && @path.length > 0
        raise(Error::ConfigurationError, "Invalid path specified: Path must contain a path to redirect to.")
      end
      unless @path.end_with?('/')
        raise(Error::ConfigurationError, "Invalid path specified: #{@path} should end with a trailing slash.")
      end

      unless @port.is_a?(Integer) && @port > 0
        raise(Error::ConfigurationError, "Invalid port specified: #{@port} must be an integer and non-zero.")
      end

      if !@sign_key.nil? && !@sign_key.is_a?(String)
        raise(Error::ConfigurationError, "Invalid sign_key specified: #{@sign_key} must be a String.")
      end

      unless @sign_length.is_a?(Integer) && @sign_length.between?(0, Signing::MAX_SIGN_LENGTH)
        raise(Error::ConfigurationError, "Invalid sign_length specified: #{@sign_length} must be an integer between 0-#{Signing::MAX_SIGN_LENGTH}.")
      end

      unless @encode_uris.is_a?(Array) && @encode_uris.count > 0
        raise(Error::ConfigurationError, "Invalid encode_uris specified: #{@encode_uris} must be an array with at least one URI scheme.")
      end

      unless @url_encoding.is_a?(Module) && Encode::ENCODERS.include?(@url_encoding)
        raise(Error::ConfigurationError, "Invalid url_encoding specified: #{@url_encoding} must be a valid encoder module.")
      end

      unless @url_decoding.is_a?(Module) && Decode::DECODERS.include?(@url_decoding)
        raise(Error::ConfigurationError, "Invalid url_decoding specified: #{@url_decoding} must be a valid decoder module.")
      end
    end
852104
public synchronized void saveHostFile() throws IOException {
		if (!hostFileWriteable) {
			throw new IOException("Host file is not writeable.");
		}

		try {
			File f = new File(knownhosts);

			FileOutputStream out = new FileOutputStream(f);

			out.write(toString().getBytes());

			out.close();
		} catch (IOException e) {
			throw new IOException("Could not write to " + knownhosts);
		}
	}
1331229
def load(self):
        """"""
        with open(self.filename) as f:
            content = f.readlines()
        content = [" ".join(x.split()).strip('\n').lstrip().split(' ', 1) for x in content]

        # removes duplicated spaces, and splits in two fields, removes leading spaces
        hosts = {}
        host = "NA"
        for line in content:
            if line[0].startswith('#') or line[0] is '':
                pass  # ignore line
            else:
                attribute = line[0]
                value = line[1]
                if attribute.lower().strip() in ['Host', 'host']:
                    host = value
                    hosts[host] = {'host': host}
                else:
                    # In case of special configuration lines, such as port
                    # forwarding,
                    # there would be no 'Host india' line.
                    if host in hosts:
                        hosts[host][attribute] = value
                        # pass
        self.hosts = hosts
387378
private function checkConfig()
    {
        if (empty($this->config['api_key'])) {
            throw new Exception("`api_key' must be configured");
        }

        if (empty($this->config['host'])) {
            throw new Exception("`host' must be configured");
        }

        if (empty($this->config['port'])) {
            $this->config['port'] = !empty($this->config['secure']) ? 443 : 80;
        }

        if (!isset($this->config['secure'])) {
            $this->config['secure'] = ($this->config['port'] == 443);
        }

        if (empty($this->config['hostname'])) {
            $this->config['hostname'] = gethostname() ? gethostname() : '<unknown>';
        }

        if (empty($this->config['project_root'])) {
            $this->config['project_root'] = dirname(__FILE__);
        }

        if (empty($this->config['environment_name'])) {
            $this->config['environment_name'] = 'development';
        }

        if (!isset($this->config['params_filters'])) {
            $this->config['params_filters'] = array('/password/');
        }

        if (!isset($this->config['connect_timeout'])) {
            $this->config['connect_timeout'] = 3;
        }

        if (!isset($this->config['write_timeout'])) {
            $this->config['write_timeout'] = 3;
        }

        if (!isset($this->config['backtrace_filters'])) {
            $this->config['backtrace_filters'] = array(
                sprintf('/^%s/', preg_quote($this->config['project_root'], '/')) => '[PROJECT_ROOT]'
            );
        }

        if (!isset($this->config['skipped_exceptions'])) {
            $this->config['skipped_exceptions'] = array();
        }

        if (!isset($this->config['default_writer'])) {
            $this->config['default_writer'] = 'Errbit\Writer\SocketWriter';
        }

        if (!isset($this->config['agent'])) {
            $this->config['agent'] = 'errbitPHP';
        }
        if (!isset($this->config['async'])) {
            $this->config['async'] = false;
        }
        if (!isset($this->config['ignore_user_agent'])) {
            $this->config['ignore_user_agent'] = array();
        }
    }
263435
def check_configuration(self, file_path, test_program, custom_args):
        """"""
        # checking filepath
        if not os.path.isdir(file_path):
            raise InvalidFilePath("INVALID CONFIGURATION: file path %s is not a directory" %
                os.path.abspath(file_path)
            )

        if not test_program in IMPLEMENTED_TEST_PROGRAMS:
            raise InvalidTestProgram('The `%s` is unknown, or not yet implemented. Please chose another one.' % test_program)

        if custom_args:
            if not self.quiet and not ask("WARNING!!!\nYou are about to run the following command\n\n   $ %s\n\nAre you sure you still want to proceed [y/N]? " % self.get_cmd()):
                raise CancelDueToUserRequest('Test cancelled...')