Write a chunk to file and update the progress bar.
178660
def _chunk_write(chunk, local_file, progress):
    """"""
    local_file.write(chunk)
    if progress is not None:
        progress.update(len(chunk))
452736
private void writeKML(ProgressVisitor progress) throws SQLException {
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(fileName);
            writeKMLDocument(progress, fos);
        } catch (FileNotFoundException ex) {
            throw new SQLException(ex);

        } finally {
            try {
                if (fos != null) {
                    fos.close();
                }
            } catch (IOException ex) {
                throw new SQLException(ex);
            }
        }
    }
571059
def _update_progress_bar(self, stdin=False):
        # type: (Uploader, bool) -> None
        
        if not self._all_files_processed:
            return
        blobxfer.operations.progress.update_progress_bar(
            self._general_options,
            'upload',
            self._upload_start_time,
            self._upload_total,
            self._upload_sofar,
            self._upload_bytes_total,
            self._upload_bytes_sofar,
            stdin_upload=stdin,
        )
153780
def update_progress(cls, progress, starttime):
        
        width, _height = click.get_terminal_size()
        if not width:
            return

        duration = datetime.utcnow() - starttime
        hours, remainder = divmod(duration.seconds, 3600)
        minutes, seconds = divmod(remainder, 60)

        size = int(width * .6)
        status = ""
        if isinstance(progress, int):
            progress = float(progress)
        if not isinstance(progress, float):
            progress = 0
            status = 'error: progress var must be float\n'
            cls.echo(type(progress))
        if progress < 0:
            progress = 0
            status = 'Halt...\n'
        if progress >= 1:
            progress = 1
            # status = 'Done...\n'
        block = int(round(size * progress))
        text = ('\rProgress: [{0}] {1:.2%} {2} {3:0>2}:{4:0>2}:{5:0>2}  '
                ''.format('#' * block + '-' * (size - block), progress,
                          status, hours, minutes, seconds))
        sys.stdout.write(text)
        sys.stdout.flush()
1025932
async function writeChunk(){
        if (chunks.length > 0){
            // get first element
            const l = chunks.shift();

            // increment size counter
            currentUploadSize += l.length;

            // write first element to file
            try{
                await _virtualTerminal.executeCommand('__nmtwrite("' + l + '")');
            }catch(e){
                _logger.debug(e);
                throw new Error('cannot write chunk to remote file');
            }

            // run progress callback
            progressCb.apply(progressCb, [currentUploadSize, absoluteFilesize]);

            // write next
            await writeChunk();

        }else{
            // ensure that the progress callback is called, even for empty files
            progressCb.apply(progressCb, [currentUploadSize, absoluteFilesize]);

            // send file close command
            try{
                await _virtualTerminal.executeCommand(_luaCommandBuilder.command.fileCloseFlush);
            }catch(e){
                _logger.debug(e);
                throw new Error('cannot flush/close remote file');
            }
        }
    }
910307
async def write_bytes(self, writer: AbstractStreamWriter,
                          conn: 'Connection') -> None:
        """"""
        # 100 response
        if self._continue is not None:
            await writer.drain()
            await self._continue

        protocol = conn.protocol
        assert protocol is not None
        try:
            if isinstance(self.body, payload.Payload):
                await self.body.write(writer)
            else:
                if isinstance(self.body, (bytes, bytearray)):
                    self.body = (self.body,)  # type: ignore

                for chunk in self.body:
                    await writer.write(chunk)  # type: ignore

            await writer.write_eof()
        except OSError as exc:
            new_exc = ClientOSError(
                exc.errno,
                'Can not write request body for %s' % self.url)
            new_exc.__context__ = exc
            new_exc.__cause__ = exc
            protocol.set_exception(new_exc)
        except asyncio.CancelledError as exc:
            if not conn.closed:
                protocol.set_exception(exc)
        except Exception as exc:
            protocol.set_exception(exc)
        finally:
            self._writer = None
42935
def write(self, *args, **kwargs):
        """"""

        self.progress_status()

        # Check abortes state and raise StopIteration if aborted
        if self.aborted:
            statustext = _("File saving aborted.")
            post_command_event(self.main_window, self.main_window.StatusBarMsg,
                               text=statustext)
            return False

        return self.parent_cls.write(self, *args, **kwargs)
380487
def write_data(self):
        """"""
        self.output_file.write(self.downloaded_file_buffer)
        self.output_file.close()
        self.finished_flag = True
330783
def write(self, args):  # pylint: disable=no-self-use
        
        ShellProgressView.done = False
        message = args.get('message', '')
        percent = args.get('percent', None)
        if percent:
            ShellProgressView.progress_bar = _format_value(message, percent)
            if int(percent) == 1:
                ShellProgressView.progress_bar = None

        ShellProgressView.progress = message
66549
def _Write(self, data, length, progress_callback=None):
        """"""
        if progress_callback:
            progress = self._HandleProgress(length, progress_callback)
            next(progress)
        while length:
            tmp = data.read(self.chunk_kb * 1024)
            length -= len(tmp)
            self.usb.BulkWrite(tmp)

            if progress_callback and progress:
                progress.send(len(tmp))
262381
def download(url, file_handle, chunk_size=1024):
    
    r = requests.get(url, stream=True)
    total_length = r.headers.get('content-length')
    if total_length is None:
        maxval = UnknownLength
    else:
        maxval = int(total_length)
    name = file_handle.name
    with progress_bar(name=name, maxval=maxval) as bar:
        for i, chunk in enumerate(r.iter_content(chunk_size)):
            if total_length:
                bar.update(i * chunk_size)
            file_handle.write(chunk)
4653
def _WritePartial(self, data):
    """"""

    chunk = self.offset // self.chunksize
    chunk_offset = self.offset % self.chunksize
    data = utils.SmartStr(data)

    available_to_write = min(len(data), self.chunksize - chunk_offset)

    fd = self._GetChunkForWriting(chunk)
    fd.seek(chunk_offset)

    fd.write(data[:available_to_write])
    self.offset += available_to_write

    return data[available_to_write:]
678853
def save(self, incoming_stream, size_limit=None, size=None,
             chunk_size=None, progress_callback=None):
        """"""
        fp = self.open(mode='wb')
        try:
            bytes_written, checksum = self._write_stream(
                incoming_stream, fp, chunk_size=chunk_size,
                progress_callback=progress_callback,
                size_limit=size_limit, size=size)
        except Exception:
            fp.close()
            self.delete()
            raise
        finally:
            fp.close()

        self._size = bytes_written

        return self.fileurl, bytes_written, checksum
640046
def update_progress(self, progress, prefix=''):
        
        total_length = 40

        if progress == 1.:
            sys.stderr.write('\r' + ' ' * (total_length + len(prefix) + 50))
            sys.stderr.write('\n')
            sys.stderr.flush()
        else:
            bar_length = int(round(total_length * progress))
            sys.stderr.write('\r%s [%s%s] %.1f %% '
                             % (prefix, '=' * bar_length,
                                ' ' * (total_length - bar_length),
                                progress * 100))
            sys.stderr.flush()
1124251
def write_chunk(self, x, z, nbt_file):
        
        data = BytesIO()
        nbt_file.write_file(buffer=data) # render to buffer; uncompressed
        self.write_blockdata(x, z, data.getvalue())
705220
def put(self, filename, totalChunks, status):
        
        logger.info('Completing ' + filename + ' - ' + status)
        self._uploadController.finalise(filename, int(totalChunks), status)
        return None, 200
778755
def progress_updater(size, total):
    """"""
    current_task.update_state(
        state=state('PROGRESS'),
        meta=dict(size=size, total=total)
    )