Выполняет указанный в конфигурации запрос и отдает файл на скачивание
        :param configuration: Конфгурация запроса
        :param output_file: Место, куда надо скачать файл
        :return:
340826
def download_data(self, configuration, output_file):
        
        params = configuration
        response = self.__app.native_api_call('metaql', 'download-data', params, self.__options, False, None, True, http_path="/api/v1/meta/")
        with open(output_file, 'wb') as out_file:
            shutil.copyfileobj(response.raw, out_file)
        del response
978241
def store(self, config_file):
        

        selfcopy = copy.deepcopy(self)
        selfcopy.filter_exports()

        with open(config_file, 'w') as outf:
            yaml.dump(
                selfcopy.node,
                outf,
                width=80,
                indent=4,
                default_flow_style=False,
                Dumper=ConfigDumper)
1165176
def output_file(self):
        
        out_files = self.output_files
        if len(out_files) != 1:
            err_msg = "output_file property is only valid if there is a single"
            err_msg += " output file. Here there are "
            err_msg += "%d output files." %(len(out_files))
            raise ValueError(err_msg)
        return out_files[0]
892261
def show(config_file=False):
    '''
    
    '''
    roots = (
        'compat',
        'debug',
        'dev',
        'hptmv',
        'hw',
        'kern',
        'machdep',
        'net',
        'p1003_1b',
        'security',
        'user',
        'vfs',
        'vm'
    )
    cmd = 'sysctl -ae'
    ret = {}
    comps = ['']

    if config_file:
        # If the file doesn't exist, return an empty list
        if not os.path.exists(config_file):
            return []

        try:
            with salt.utils.files.fopen(config_file, 'r') as f:
                for line in f.readlines():
                    l = line.strip()
                    if l != "" and not l.startswith("#"):
                        comps = line.split('=', 1)
                        ret[comps[0]] = comps[1]
            return ret
        except (OSError, IOError):
            log.error('Could not open sysctl config file')
            return None
    else:
        out = __salt__['cmd.run'](cmd, output_loglevel='trace')
        for line in out.splitlines():
            if any([line.startswith('{0}.'.format(root)) for root in roots]):
                comps = line.split('=', 1)
                ret[comps[0]] = comps[1]
            elif comps[0]:
                ret[comps[0]] += '{0}\n'.format(line)
            else:
                continue
        return ret
706646
def get_configuration(config_file=None):
    
    parser = configparser.ConfigParser()
    if config_file is None:
        # fallback to default user config file
        config_file = os.path.join(os.getenv("HOME"), DEFAULT_USER_INI)
        if not os.path.isfile(config_file):
            config_file = None
    else:
        if not os.path.isfile(config_file):
            raise ValueError("%s is not a file" % config_file)

    configs = [get_filename(PRESETS_INI)]
    if config_file:
        configs.append(config_file)
    LOG.debug("Attempting to read configuration from %r", configs)
    read_configs = parser.read(configs)
    LOG.debug("Successfully read configuration from %r", read_configs)
    LOG.debug("config file sections: %r", parser.sections())
    return parser
216564
def write_config_file(self, f, comments):
        
        if self.conf_hidden:
            return False

        if comments:
            f.write("\n")
            f.write("# Attribute (")
            f.write(str(self.e_type.__name__))
            f.write(") : ")
            f.write(self._name.upper())
            f.write("\n")
            if self._desc and self._desc != argparse.SUPPRESS:
                f.write("# Description : ")
                for i in self._desc.split('\n'):
                    f.write("# ")
                    f.write(i)
                    f.write("\n")
                f.write("\n")

        if not self.conf_required:
            f.write(";")
        f.write(self._name)
        f.write("=")
        if self.default is not None and not self.hidden:
            f.write(str(self.default))
        f.write("\n")
926485
def show(config_file=False):
    '''
    
    '''
    cmd = 'sysctl'
    ret = {}
    out = __salt__['cmd.run_stdout'](cmd, output_loglevel='trace')
    for line in out.splitlines():
        if not line or '=' not in line:
            continue
        comps = line.split('=', 1)
        ret[comps[0]] = comps[1]
    return ret
128550
def configure(self, config_file):
        
        cfg = configparser.RawConfigParser()
        try:
            cfg.readfp(open(config_file))
        except IOError as err:
            logger.critical(
                'Error while reading config file {}: {}'.format(
                    config_file, err.strerror))
            sys.exit(1)
        logger.info('Parsed config file ' + config_file)

        # Extract user-defined log level from configuration
        if cfg.has_option('milter', 'loglevel'):
            loglevel = cfg.get('milter', 'loglevel')
            loglevel_numeric = getattr(logging, loglevel.upper(), None)
            if not isinstance(loglevel_numeric, int):
                logger.critical(
                    'Config contains unsupported loglevel: ' + loglevel)
                exit(1)
            rl = logging.getLogger()
            rl.setLevel(loglevel_numeric)
            logger.debug(
                'Config option applied: milter->loglevel: {}'.format(loglevel))

        # Apply all config options to their respective classes
        section_class_map = {
            'milter': self,
            'dspam': DspamClient,
            'classification': DspamMilter,
        }
        for section in cfg.sections():
            try:
                class_ = section_class_map[section]
            except KeyError:
                logger.warning('Config contains unknown section: ' + section)
                continue
            logger.debug('Handling config section: ' + section)

            dict_options = [
                'headers',
                'reject_classes',
                'quarantine_classes',
                'accept_classes'
            ]
            for option in cfg.options(section):
                # Kludge: static_user needs to be set on the milter,
                #   not on the client
                if section == 'dspam' and option == 'static_user':
                    value = cfg.get('dspam', 'static_user')
                    DspamMilter.static_user = value
                    logger.debug(
                        'Config option applied: dspam->static_user: {}'.format(
                            value))
                    continue

                if not hasattr(class_, option):
                    logger.warning(
                        'Config contains unknown option: {}->{}'.format(
                            section, option))
                    continue

                value = cfg.get(section, option)
                if option in dict_options:
                    value = utils.config_str2dict(value)
                elif value.lower() in ['false', 'no']:
                    value = False
                elif value.lower() in ['true', 'yes']:
                    value = True

                setattr(class_, option, value)
                logger.debug(
                    'Config option applied: {}->{}: {}'.format(
                        section, option, value))
        logger.debug('Configuration completed')
493339
def load_configuration(self, configuration_file):
        '''
        '''
        if os.path.isfile(configuration_file):
            if not isinstance(configuration_file, tb.file.File) and os.path.splitext(configuration_file)[1].strip().lower() != ".h5":
                load_configuration_from_text_file(self, configuration_file)
            else:
                load_configuration_from_hdf5(self, configuration_file)
        else:
            raise ValueError('Cannot find configuration file specified: %s' % configuration_file)
577901
def load_file(file)
      config = self.class.load_from_file(file, default: false, logger: @log)
      config = self.class.default_configuration.merge(config)

      if @options.fetch(:verify) { config.verify_signatures? }
        verify_signatures(config)
      end

      config
    rescue Overcommit::Exceptions::ConfigurationSignatureChanged
      raise
    rescue StandardError => error
      raise Overcommit::Exceptions::ConfigurationError,
            "Unable to load configuration from '#{file}': #{error}",
            error.backtrace
    end
825577
def _find_config(self, config_file):
        
        msg = ('Configuration file [ %s ] was not found.' % self.filename)
        self.log.fatal(msg)
        raise IOError(msg)
1000196
def configToJson(self, fileName):
        
        config = self.getConfig()
        with open(fileName, "w") as outfile:
            dump(config, outfile, indent=4, sort_keys=True)
443616
def append_config_file(filename, line)
      File.open(filename, "a") { |f| f.puts(line) }
    end
141593
public void saveWithTrainingConfig(File outputFile) throws IOException {
        if(this.trainingConfig == null) {
            throw new IllegalStateException("No training configuration found!");
        }

        try(BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(outputFile))) {
            saveWithTrainingConfig(this.trainingConfig, bufferedOutputStream);
            bufferedOutputStream.flush();
        }

    }
666903
def write_config_file(self, f, comments):
        
        if comments:
            f.write("#####################################\n")
            f.write("# Section : ")
            f.write("#".join(self.get_representation()) + "\n")
            f.write("#####################################\n")
        f.write("[" + self._name + "]\n")
        if self._desc and comments:
            f.write("# Description : ")
            for i in self._desc.split('\n'):
                f.write("# ")
                f.write(i)
                f.write("\n")
            f.write("\n")
958474
def relevant_configuration_file(options)
      if options[:config_file]
        options[:config_file]
      elsif File.exist?(Config::FILE_NAME)
        Config::FILE_NAME
      elsif File.exist?(Config.user_file)
        Config.user_file
      end
    end
987749
def parse_config_output(self, output):
        
        regexp = re.compile('^(config |edit |set |end$|next$)(.*)')
        current_block = self

        if isinstance(output, py23_compat.string_types):
            output = output.splitlines()

        for line in output:
            if 'uuid' in line:
                continue
            if 'snmp-index' in line:
                continue
            line = line.strip()
            result = regexp.match(line)

            if result is not None:
                action = result.group(1).strip()
                data = result.group(2).strip()

                if action == 'config' or action == 'edit':
                    data = data.replace('"', '')
                    if data not in current_block.get_block_names():
                        config_block = FortiConfig(data, action, current_block)
                        current_block[data] = config_block
                    else:
                        config_block = current_block[data]
                    current_block = config_block
                elif action == 'end' or action == 'next':
                    current_block = current_block.get_parent()
                elif action == 'set':
                    split_data = data.split(' ')
                    parameter = split_data[0]
                    data = split_data[1:]
                    current_block.set_param(parameter, ' '.join(data))