Write raw response data into a file.

        .. versionadded:: 4.2.1
517661
def write_raw(self, resp: Union[bytes, requests.Response], filename: str) -> None:
        """"""
        self.log(filename, end=' ', flush=True)
        with open(filename, 'wb') as file:
            if isinstance(resp, requests.Response):
                shutil.copyfileobj(resp.raw, file)
            else:
                file.write(resp)
767131
def save_to_disk
      FileUtils.mkdir_p(File.dirname(answer_file_path))

      write_file(answer_file_path, JSON.pretty_generate(answers))
    rescue SystemCallError, IOError => e
      raise PDK::CLI::FatalError, _("Unable to write '%{file}': %{msg}") % {
        file: answer_file_path,
        msg:  e.message,
      }
    end
219105
def write_raw(path, raw):
    '''
    
    '''
    log.debug('Writing vault secrets for %s at %s', __grains__['id'], path)
    try:
        url = 'v1/{0}'.format(path)
        response = __utils__['vault.make_request']('POST', url, json=raw)
        if response.status_code == 200:
            return response.json()['data']
        elif response.status_code != 204:
            response.raise_for_status()
        return True
    except Exception as err:
        log.error('Failed to write secret! %s: %s', type(err).__name__, err)
        return False
847389
def _stream_raw_result(self, response, chunk_size=1, decode=True):
        ''' '''
        self._raise_for_status(response)
        for out in response.iter_content(chunk_size, decode):
            yield out
1362484
def _write(self):
        
        self.json_file.seek(0)
        self.json_file.truncate()
        dump = json.dumps(self.backup_dict)
        dump_c = zlib.compress(dump.encode('utf-8'))
        self.json_file.write(dump_c)
241349
def _dump(file_obj, options, out=sys.stdout):
    """"""
    # writer and keys are lazily loaded. We don't know the keys until we have
    # the first item. And we need the keys for the csv writer.
    total_count = 0
    writer = None
    keys = None
    for row in DictReader(file_obj, options.col):
        if not keys:
            keys = row.keys()
        if not writer:
            writer = csv.DictWriter(out, keys, delimiter=u'\t', quotechar=u'\'', quoting=csv.QUOTE_MINIMAL) \
                if options.format == 'csv' \
                else JsonWriter(out) if options.format == 'json' \
                else None
        if total_count == 0 and options.format == "csv" and not options.no_headers:
            writer.writeheader()
        if options.limit != -1 and total_count >= options.limit:
            return
        row_unicode = {k: v.decode("utf-8") if isinstance(v, bytes) else v for k, v in row.items()}
        writer.writerow(row_unicode)
        total_count += 1
11441
def create_response(self, data=None):
        
        frame = deepcopy(self)
        if data is not None:
            frame.data = data
        frame.length = 2 + len(frame.data)
        return frame
812664
def dump(self, raw=False):
        '''  '''
        raw_out = self.ser.read(self.ser.in_waiting)
        if raw:
            return raw_out
        return raw_out.decode(OUTPUT_ENCODING)
524022
def dump(self, fileobj):
        ''''''
        if self.file_format == 'csv':
            csv.writer(fileobj).writerows(self.raw_dict().items())
        elif self.file_format == 'json':
            json.dump(self.raw_dict(), fileobj, separators=(',', ':'))
        elif self.file_format == 'pickle':
            pickle.dump(dict(self.raw_dict()), fileobj, 2)
        else:
            raise NotImplementedError('Unknown format: ' +
                                      repr(self.file_format))
715164
def save_headers(cls, filename: str, response: HTTPResponse):
        '''
        '''
        new_filename = filename + '-new'

        with open('wb') as new_file:
            new_file.write(response.header())

            with wpull.util.reset_file_offset(response.body):
                response.body.seek(0)
                shutil.copyfileobj(response.body, new_file)

        os.remove(filename)
        os.rename(new_filename, filename)
1092027
def write_baseline_to_file(filename, data):
    
    with open(filename, 'w') as f:  # pragma: no cover
        f.write(format_baseline_for_output(data) + '\n')
616552
def submit_recording(raw_data_json):
    
    url = "http://www.martin-thoma.de/write-math/classify/index.php"
    headers = {'User-Agent': 'Mozilla/5.0',
               'Content-Type': 'application/x-www-form-urlencoded'}
    payload = {'drawnJSON': raw_data_json}

    s = requests.Session()
    req = requests.Request('POST', url, headers=headers, data=payload)
    prepared = req.prepare()
    s.send(prepared)
191748
def save(filename, path, params={})
      payload = get! path, nil, params
      File.write filename, payload.response.body
    end
977220
def write(self, filename, append=True):
        
        header = ' '.join(['# User:', getpass.getuser(),
                           '\n# Creation date:', str(UTCDateTime()),
                           '\n# EQcorrscan version:',
                           str(eqcorrscan.__version__),
                           '\n\n\n'])
        if append:
            f = open(filename, 'a')
        else:
            f = open(filename, 'w')
            f.write(header)
        parameters = self.__dict__
        f.write(str(parameters))
        f.write('\n')
        f.close()
        return
469866
def write_to_file(self,
                      data_dict,
                      output_file_path):
        

        log.info("saving={}".format(output_file_path))
        with open(output_file_path, "w") as output_file:
            output_file.write(str(ppj(data_dict)))
250862
def write_data(self, data, response_required=None, timeout=5.0, raw=False):
        """"""
        if self._transport is None:
            return

        if self._paused:
            return

        if self._waiting_for_response:
            LOG.debug("queueing write %s", data)
            self._queued_writes.append((data, response_required, timeout))
            return

        if response_required:
            self._waiting_for_response = response_required
            if timeout > 0:
                self._timeout_task = self.loop.call_later(
                    timeout, self._response_required_timeout)

        if not raw:
            cksum = 256 - reduce(lambda x, y: x+y, map(ord, data)) % 256
            data = data + '{:02X}'.format(cksum)
            if int(data[0:2], 16) != len(data)-2:
                LOG.debug("message length wrong: %s", data)

        LOG.debug("write_data '%s'", data)
        self._transport.write((data + '\r\n').encode())
625826
def SaveData(self, raw_data):
    """"""
    if self.filename is None:
      raise IOError("Unknown filename")

    logging.info("Writing back configuration to file %s", self.filename)
    # Ensure intermediate directories exist
    try:
      os.makedirs(os.path.dirname(self.filename))
    except (IOError, OSError):
      pass

    try:
      # We can not use the standard open() call because we need to
      # enforce restrictive file permissions on the created file.
      mode = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
      fd = os.open(self.filename, mode, 0o600)
      with os.fdopen(fd, "wb") as config_file:
        self.SaveDataToFD(raw_data, config_file)

    except OSError as e:
      logging.warning("Unable to write config file %s: %s.", self.filename, e)