def _update(self): #if self.hbox.parent.parent.parent.props.visible: if self.hci != None: devinfo = Lib.device_info(self.hci) _tx = devinfo["stat"]["byte_tx"] _rx = devinfo["stat"]["byte_rx"] tx, s_tx = format_bytes(_tx) rx, s_rx = format_bytes(_rx) _u_speed = self.up_speed.calc(_tx) _d_speed = self.down_speed.calc(_rx) self.set_blinker_by_speed(self.up_blinker, _u_speed) self.set_blinker_by_speed(self.down_blinker, _d_speed) u_speed, s_u_speed = format_bytes(_u_speed) d_speed, s_d_speed = format_bytes(_d_speed) self.set_data(tx, s_tx, rx, s_rx, u_speed, s_u_speed, d_speed, s_d_speed) return 1
def on_transfer_progress(self, _transfer, progress): self.transferred = progress if self._last_bytes == 0: self.total_transferred += progress else: self.total_transferred += (progress - self._last_bytes) self._last_bytes = progress tm = time.time() if tm - self._last_update > 0.5: spd = self.speed.calc(self.total_transferred) (size, units) = format_bytes(spd) try: x = ((self.total_bytes - self.total_transferred) / spd) + 1 if x > 60: x /= 60 eta = ngettext("%.0f Minute", "%.0f Minutes", round(x)) % x else: eta = ngettext("%.0f Second", "%.0f Seconds", round(x)) % x except ZeroDivisionError: eta = "∞" self.pb.props.text = _("Sending File") + (" %(0)s/%(1)s (%(2).2f %(3)s/s) " + _("ETA:") + " %(4)s") % { "1": self.num_files, "0": (self.num_files - len(self.files) + 1), "2": size, "3": units, "4": eta} self._last_update = tm self.pb.props.fraction = float(self.total_transferred) / self.total_bytes
def _update(self): if self.hci is not None: devinfo = device_info(self.hci) _tx = devinfo["stat"]["byte_tx"] _rx = devinfo["stat"]["byte_rx"] tx, s_tx = format_bytes(_tx) rx, s_rx = format_bytes(_rx) _u_speed = self.up_speed.calc(_tx) _d_speed = self.down_speed.calc(_rx) self.set_blinker_by_speed(self.up_blinker, _u_speed) self.set_blinker_by_speed(self.down_blinker, _d_speed) u_speed, s_u_speed = format_bytes(_u_speed) d_speed, s_d_speed = format_bytes(_d_speed) self.set_data(tx, s_tx, rx, s_rx, u_speed, s_u_speed, d_speed, s_d_speed) return 1