def new_reader_status(self): if self.app.iostatuspanel: self.app.iostatuspanel.update() now = time.time() seconds = math.floor(now) if self.last_status_update == seconds: if self.next_status_update: return self.next_status_update = self.browser.root.after( 1000 - int(1000*(now%1.0)), self.new_reader_status) return self.last_status_update = seconds self.next_status_update = None if self.readers: nr = len(self.readers) nw = 0 if nr == 1: message = str(self.readers[0]) else: nbytes = 0 maxbytes = 0 cached = 0 for reader in self.readers: nbytes = nbytes + reader.nbytes if reader.message == "waiting for socket": nw = nw + 1 if reader.maxbytes > 0 and maxbytes >= 0: maxbytes = maxbytes + reader.maxbytes else: maxbytes = -1 if reader.api.iscached(): cached = cached + 1 if maxbytes > 0: percent = nbytes*100/maxbytes message = "%d%% of %s read" % ( percent, grailutil.nicebytes(maxbytes)) else: message = "%s read" % grailutil.nicebytes(nbytes) if cached == nr: message = message + " (all cached)" elif cached: message = message + " (%d cached)" % cached message = "%d streams, %d active: %s" % (nr, nr - nw, message) elif self.on_top(): message = "" elif self.get_url(): message = "URL: %s" % self.get_url() else: message = "empty" self.message(message)
def new_reader_status(self): if self.app.iostatuspanel: self.app.iostatuspanel.update() now = time.time() seconds = math.floor(now) if self.last_status_update == seconds: if self.next_status_update: return self.next_status_update = self.browser.root.after( 1000 - int(1000 * (now % 1.0)), self.new_reader_status) return self.last_status_update = seconds self.next_status_update = None if self.readers: nr = len(self.readers) nw = 0 if nr == 1: message = str(self.readers[0]) else: nbytes = 0 maxbytes = 0 cached = 0 for reader in self.readers: nbytes = nbytes + reader.nbytes if reader.message == "waiting for socket": nw = nw + 1 if reader.maxbytes > 0 and maxbytes >= 0: maxbytes = maxbytes + reader.maxbytes else: maxbytes = -1 if reader.api.iscached(): cached = cached + 1 if maxbytes > 0: percent = nbytes * 100 / maxbytes message = "%d%% of %s read" % ( percent, grailutil.nicebytes(maxbytes)) else: message = "%s read" % grailutil.nicebytes(nbytes) if cached == nr: message = message + " (all cached)" elif cached: message = message + " (%d cached)" % cached message = "%d streams, %d active: %s" % (nr, nr - nw, message) elif self.on_top(): message = "" elif self.get_url(): message = "URL: %s" % self.get_url() else: message = "empty" self.message(message)
def __str__(self): if self.maxbytes: percent = self.nbytes * 100 / self.maxbytes status = "%d%% of %s read" % (percent, grailutil.nicebytes(self.maxbytes)) elif not self.nbytes: status = self.message else: status = "%s read" % grailutil.nicebytes(self.nbytes) if self.api and self.api.iscached(): status = status + " (cached)" if self.api and not self.shorturl: tuple = urlparse.urlparse(self.api._url_) path = tuple[2] i = string.rfind(path[:-1], '/') if i >= 0: path = path[i + 1:] self.shorturl = path or self.api._url_ return "%s: %s" % (self.shorturl, status)
def __str__(self): if self.maxbytes: percent = self.nbytes*100/self.maxbytes status = "%d%% of %s read" % (percent, grailutil.nicebytes(self.maxbytes)) elif not self.nbytes: status = self.message else: status = "%s read" % grailutil.nicebytes(self.nbytes) if self.api and self.api.iscached(): status = status + " (cached)" if self.api and not self.shorturl: tuple = urlparse.urlparse(self.api._url_) path = tuple[2] i = string.rfind(path[:-1], '/') if i >= 0: path = path[i+1:] self.shorturl = path or self.api._url_ return "%s: %s" % (self.shorturl, status)
def make_progress_bar(self, size, frame): self.__bytespat = "%.1f%% of " + grailutil.nicebytes(size) self.__maxsize = 1.0 * size # make it a float for future calc. f = Frame(frame, relief=SUNKEN, borderwidth=1, background=LIGHT_BLUE, height=20, width=202) f.pack(pady='1m') self.__progbar = Frame(f, width=1, background=DARK_BLUE, height=string.atoi(str(f.cget('height'))) - 2*string.atoi(str(f.cget('borderwidth')))) self.__progbar.place(x=0, y=0)
def make_progress_bar(self, size, frame): self.__bytespat = "%.1f%% of " + grailutil.nicebytes(size) self.__maxsize = 1.0 * size # make it a float for future calc. f = Frame(frame, relief=SUNKEN, borderwidth=1, background=LIGHT_BLUE, height=20, width=202) f.pack(pady='1m') self.__progbar = Frame(f, width=1, background=DARK_BLUE, height=string.atoi(f.cget('height')) - 2*string.atoi(f.cget('borderwidth'))) self.__progbar.place(x=0, y=0)