'Update progressbar with current value of process.
Parameters
cur_value : number
Current value of process.  Should be <= max_value (but this is not
enforced).  The percent of the progressbar will be computed as
(cur_value / max_value) * 100
mesg : str
Message to display to the right of the progressbar.  If None, the
last message provided will be used.  To clear the current message,
pass a null string, \'\'.'

def update(self, cur_value, mesg=None):

    self.cur_value = cur_value
    progress = min((float(self.cur_value) / self.max_value), 1.0)
    num_chars = int((progress * self.max_chars))
    num_left = (self.max_chars - num_chars)
    if (mesg is not None):
        if (mesg == 'file_sizes'):
            mesg = ('(%s    /    %s)' % (sizeof_fmt(self.cur_value), sizeof_fmt(self.max_value)))
        self.mesg = mesg
    bar = self.template.format((self.progress_character * num_chars), ('    ' * num_left), (progress * 100), self.spinner_symbols[self.spinner_index], self.mesg)
    if self._do_print:
        sys.stdout.write(bar)
        sys.stdout.flush()
    if self.spinner:
        self.spinner_index = ((self.spinner_index + 1) % self.n_spinner)
