示例#1
0
    def UpdateInfo(self, stats, to_cleanup=False):
        if to_cleanup:
            for info in self.__info_list:
                info[1] = DATA_NONE
        else:
            self.__info_list[0][1] = "%s:%d" % stats.wan_address
            self.__info_list[1][1] = "%s:%d" % stats.lan_address
            self.__info_list[2][1] = unicode(stats.connection_type)

            self.__info_list[3][1] = "%s" % eta_value(stats.timestamp -
                                                      stats.start)
            self.__info_list[4][1] = "%s or %s/s" % (
                size_format(stats.total_down),
                size_format(
                    int(stats.total_down / (stats.timestamp - stats.start))))
            self.__info_list[5][1] = "%s or %s/s" % (
                size_format(stats.total_up),
                size_format(
                    int(stats.total_up / (stats.timestamp - stats.start))))
            self.__info_list[6][1] = compute_ratio(
                stats.total_send, stats.total_received + stats.total_send)
            self.__info_list[7][1] = compute_ratio(
                stats.total_received, stats.total_received + stats.total_send)
            self.__info_list[8][1] = compute_ratio(
                stats.msg_statistics.success_count, stats.total_received)
            self.__info_list[9][1] = compute_ratio(
                stats.msg_statistics.drop_count, stats.total_received)
            self.__info_list[10][1] = compute_ratio(
                stats.msg_statistics.delay_received_count,
                stats.total_received)
            self.__info_list[11][1] = compute_ratio(
                stats.msg_statistics.delay_send_count,
                stats.msg_statistics.delay_received_count)
            self.__info_list[12][1] = compute_ratio(
                stats.msg_statistics.delay_success_count,
                stats.msg_statistics.delay_received_count)
            self.__info_list[13][1] = compute_ratio(
                stats.msg_statistics.delay_timeout_count,
                stats.msg_statistics.delay_received_count)
            self.__info_list[14][1] = compute_ratio(stats.walk_success_count,
                                                    stats.walk_attempt_count)
            self.__info_list[15][1] = "%s" % stats.msg_statistics.created_count
            self.__info_list[16][1] = compute_ratio(
                sum(c.sync_bloom_new for c in stats.communities),
                sum(c.sync_bloom_send + c.sync_bloom_skip
                    for c in stats.communities))
            self.__info_list[17][1] = compute_ratio(
                sum(c.sync_bloom_reuse for c in stats.communities),
                sum(c.sync_bloom_send + c.sync_bloom_skip
                    for c in stats.communities))
            self.__info_list[18][1] = compute_ratio(
                sum(c.sync_bloom_skip for c in stats.communities),
                sum(c.sync_bloom_send + c.sync_bloom_skip
                    for c in stats.communities))
            self.__info_list[19][1] = "yes" if __debug__ else "no"

        for key, value, _ in self.__info_list:
            self.__text_dict[key].SetLabel(value)

        self.SetupScrolling()
示例#2
0
    def OnUpdateCircuits(self, event):
        if not self.tunnel_community:
            return

        if self.fullscreen:
            self.num_circuits_label.SetLabel(
                "You have %d circuit(s); %d relay(s); %d exit socket(s); %d candidate(s)"
                % (len(self.tunnel_community.circuits),
                   len(self.tunnel_community.relay_from_to),
                   len(self.tunnel_community.exit_sockets),
                   sum(1 for _ in self.tunnel_community.
                       dispersy_yield_verified_candidates())))

        new_circuits = dict(self.tunnel_community.circuits)
        self.circuits = {
            k: v
            for k, v in new_circuits.iteritems()
            if v.goal_hops == self.hops or self.hops < 0
        }

        # Add new circuits & update existing circuits
        for circuit_id, circuit in self.circuits.iteritems():
            if circuit_id not in self.circuit_to_listindex:
                pos = self.circuit_list.InsertStringItem(
                    sys.maxsize, str(circuit_id))
                self.circuit_to_listindex[circuit_id] = pos
            else:
                pos = self.circuit_to_listindex[circuit_id]
            self.circuit_list.SetStringItem(pos, 1, str(circuit.state))
            self.circuit_list.SetStringItem(
                pos, 2,
                str(len(circuit.hops)) + "/" + str(circuit.goal_hops))

            bytes_uploaded = circuit.bytes_up
            bytes_downloaded = circuit.bytes_down

            self.circuit_list.SetStringItem(pos, 3,
                                            size_format(bytes_uploaded))
            self.circuit_list.SetStringItem(pos, 4,
                                            size_format(bytes_downloaded))
            self.circuit_list.SetStringItem(
                pos, 5, "%d" % (time() - circuit.creation_time))

        # Remove old circuits
        old_circuits = [
            circuit_id for circuit_id in self.circuit_to_listindex
            if circuit_id not in self.circuits
        ]
        for circuit_id in old_circuits:
            listindex = self.circuit_to_listindex[circuit_id]
            self.circuit_list.DeleteItem(listindex)
            self.circuit_to_listindex.pop(circuit_id)
            for k, v in self.circuit_to_listindex.items():
                if v > listindex:
                    self.circuit_to_listindex[k] = v - 1

        self.graph_panel.Refresh()
示例#3
0
def print_info(dispersy):
    stats = dispersy.statistics
    print >> sys.stderr, u"\n\n===== Dispersy Info ====="
    print >> sys.stderr, u"- WAN Address %s:%d" % stats.wan_address
    print >> sys.stderr, u"- LAN Address %s:%d" % stats.lan_address
    print >> sys.stderr, u"- Connection: %s" % unicode(stats.connection_type)
    print >> sys.stderr, u"- Runtime: %s" % eta_value(stats.timestamp -
                                                      stats.start)
    print >> sys.stderr, u"- Download: %s or %s/s" % (
        size_format(stats.total_down),
        size_format(int(stats.total_down / (stats.timestamp - stats.start))))
    print >> sys.stderr, u"- Upload: %s or %s/s" % (
        size_format(stats.total_up),
        size_format(int(stats.total_up / (stats.timestamp - stats.start))))
    print >> sys.stderr, u"- Packets Sent: %s" % compute_ratio(
        stats.total_send, stats.total_received + stats.total_send)
    print >> sys.stderr, u"- Packets Received: %s" % compute_ratio(
        stats.total_received, stats.total_received + stats.total_send)
    print >> sys.stderr, u"- Packets Success: %s" % compute_ratio(
        stats.msg_statistics.success_count, stats.total_received)
    print >> sys.stderr, u"- Packets Dropped: %s" % compute_ratio(
        stats.msg_statistics.drop_count, stats.total_received)
    print >> sys.stderr, u"- Packets Delayed: %s" % compute_ratio(
        stats.msg_statistics.delay_received_count, stats.total_received)
    print >> sys.stderr, u"- Packets Delayed send: %s" % compute_ratio(
        stats.msg_statistics.delay_send_count,
        stats.msg_statistics.delay_received_count)
    print >> sys.stderr, u"- Packets Delayed success: %s" % compute_ratio(
        stats.msg_statistics.delay_success_count,
        stats.msg_statistics.delay_received_count)
    print >> sys.stderr, u"- Packets Delayed timeout: %s" % compute_ratio(
        stats.msg_statistics.delay_timeout_count,
        stats.msg_statistics.delay_received_count)
    print >> sys.stderr, u"- Walker Success: %s" % compute_ratio(
        stats.walk_success_count, stats.walk_attempt_count)
    print >> sys.stderr, u"- Sync-Messages Created: %s" % stats.msg_statistics.created_count
    print >> sys.stderr, u"- Bloom New: %s" % compute_ratio(
        sum(c.sync_bloom_new for c in stats.communities),
        sum(c.sync_bloom_send + c.sync_bloom_skip for c in stats.communities))
    print >> sys.stderr, u"- Bloom Reused: %s" % compute_ratio(
        sum(c.sync_bloom_reuse for c in stats.communities),
        sum(c.sync_bloom_send + c.sync_bloom_skip for c in stats.communities))
    print >> sys.stderr, u"- Bloom Skipped: %s" % compute_ratio(
        sum(c.sync_bloom_skip for c in stats.communities),
        sum(c.sync_bloom_send + c.sync_bloom_skip for c in stats.communities))
    print >> sys.stderr, u"- Debug Mode: %s" % u"yes" if __debug__ else u"no"
    print >> sys.stderr, u"====================\n\n"
示例#4
0
    def AddFileList(self, tdef, selectedFiles, vSizer, index):
        self.listCtrl = CheckSelectableListCtrl(self)
        self.listCtrl.InsertColumn(0, 'Name')
        self.listCtrl.InsertColumn(1, 'Size', wx.LIST_FORMAT_RIGHT)

        # Add files
        def sort_by_size(a, b):
            return cmp(a[1], b[1])

        files = tdef.get_files_as_unicode_with_length()
        files.sort(sort_by_size, reverse=True)

        for filename, size in files:
            try:
                pos = self.listCtrl.InsertStringItem(sys.maxsize, filename)
            except:
                try:
                    pos = self.listCtrl.InsertStringItem(
                        sys.maxsize, filename.decode('utf-8', 'ignore'))
                except:
                    self._logger.error("Could not format filename %s",
                                       self.torrent.name)
            self.listCtrl.SetItemData(pos, pos)
            self.listCtrl.SetStringItem(pos, 1, size_format(size))

            if selectedFiles:
                self.listCtrl.CheckItem(pos, filename in selectedFiles)

        if selectedFiles is None:
            self.listCtrl.doSelectAll()

        self.listCtrl.setResizeColumn(0)
        self.listCtrl.SetColumnWidth(
            1, wx.LIST_AUTOSIZE)  # autosize only works after adding rows
        vSizer.Insert(index, self.listCtrl, 1, wx.EXPAND | wx.BOTTOM, 3)

        self.listCtrl.SetFocus()

        def OnChar(event):
            if event.GetKeyCode() == wx.WXK_RETURN:
                self.OnOk()
            else:
                event.Skip()

        self.listCtrl.Bind(wx.EVT_CHAR, OnChar)

        vSizer.Insert(
            index,
            wx.StaticText(
                self, -1,
                'Use the checkboxes to choose which files to download.\nUse ctrl+a to select all/deselect all.'
            ), 0, wx.BOTTOM, 3)

        firstLine = wx.StaticText(self, -1, "Content:")
        _set_font(firstLine, fontweight=wx.FONTWEIGHT_BOLD)
        vSizer.Insert(index, firstLine, 0, wx.BOTTOM, 3)

        vSizer.Insert(index, wx.StaticLine(self, -1), 0, wx.EXPAND | wx.BOTTOM,
                      10)
示例#5
0
    def UpdateInfo(self, stats, to_cleanup=False):
        if to_cleanup:
            for info in self.__info_list:
                info[1] = DATA_NONE
        else:
            self.__info_list[0][1] = "%s:%d" % stats.wan_address
            self.__info_list[1][1] = "%s:%d" % stats.lan_address
            self.__info_list[2][1] = unicode(stats.connection_type)

            self.__info_list[3][1] = "%s" % eta_value(stats.timestamp - stats.start)
            self.__info_list[4][1] = "%s or %s/s" % (
                size_format(stats.total_down),
                size_format(int(stats.total_down / (stats.timestamp - stats.start)))
            )
            self.__info_list[5][1] = "%s or %s/s" % (
                size_format(stats.total_up),
                size_format(int(stats.total_up / (stats.timestamp - stats.start)))
            )
            self.__info_list[6][1] = compute_ratio(stats.total_send, stats.total_received + stats.total_send)
            self.__info_list[7][1] = compute_ratio(stats.total_received, stats.total_received + stats.total_send)
            self.__info_list[8][1] = compute_ratio(stats.msg_statistics.success_count, stats.total_received)
            self.__info_list[9][1] = compute_ratio(stats.msg_statistics.drop_count, stats.total_received)
            self.__info_list[10][1] = compute_ratio(stats.msg_statistics.delay_received_count, stats.total_received)
            self.__info_list[11][1] = compute_ratio(stats.msg_statistics.delay_send_count,
                                                    stats.msg_statistics.delay_received_count)
            self.__info_list[12][1] = compute_ratio(stats.msg_statistics.delay_success_count,
                                                    stats.msg_statistics.delay_received_count)
            self.__info_list[13][1] = compute_ratio(stats.msg_statistics.delay_timeout_count,
                                                    stats.msg_statistics.delay_received_count)
            self.__info_list[14][1] = compute_ratio(stats.walk_success_count, stats.walk_attempt_count)
            self.__info_list[15][1] = "%s" % stats.msg_statistics.created_count
            self.__info_list[16][1] = compute_ratio(sum(c.sync_bloom_new for c in stats.communities),
                                                    sum(c.sync_bloom_send + c.sync_bloom_skip
                                                        for c in stats.communities))
            self.__info_list[17][1] = compute_ratio(sum(c.sync_bloom_reuse for c in stats.communities),
                                                    sum(c.sync_bloom_send + c.sync_bloom_skip
                                                        for c in stats.communities))
            self.__info_list[18][1] = compute_ratio(sum(c.sync_bloom_skip for c in stats.communities),
                                                    sum(c.sync_bloom_send + c.sync_bloom_skip
                                                        for c in stats.communities))
            self.__info_list[19][1] = "yes" if __debug__ else "no"

        for key, value, _ in self.__info_list:
            self.__text_dict[key].SetLabel(value)

        self.SetupScrolling()
示例#6
0
文件: home.py 项目: Antiade/tribler
    def OnUpdateCircuits(self, event):
        if not self.tunnel_community:
            return

        if self.fullscreen:
            self.num_circuits_label.SetLabel("You have %d circuit(s); %d relay(s); %d exit socket(s); %d candidate(s)" %
                                             (len(self.tunnel_community.circuits),
                                              len(self.tunnel_community.relay_from_to),
                                              len(self.tunnel_community.exit_sockets),
                                              sum(1 for _ in self.tunnel_community.dispersy_yield_verified_candidates())))

        new_circuits = dict(self.tunnel_community.circuits)
        self.circuits = {k: v for k, v in new_circuits.iteritems() if v.goal_hops == self.hops or self.hops < 0}

        # Add new circuits & update existing circuits
        for circuit_id, circuit in self.circuits.iteritems():
            if circuit_id not in self.circuit_to_listindex:
                pos = self.circuit_list.InsertStringItem(sys.maxsize, str(circuit_id))
                self.circuit_to_listindex[circuit_id] = pos
            else:
                pos = self.circuit_to_listindex[circuit_id]
            self.circuit_list.SetStringItem(pos, 1, str(circuit.state))
            self.circuit_list.SetStringItem(pos, 2, str(len(circuit.hops)) + "/" + str(circuit.goal_hops))

            bytes_uploaded = circuit.bytes_up
            bytes_downloaded = circuit.bytes_down

            self.circuit_list.SetStringItem(pos, 3, size_format(bytes_uploaded))
            self.circuit_list.SetStringItem(pos, 4, size_format(bytes_downloaded))
            self.circuit_list.SetStringItem(pos, 5, "%d" % (time() - circuit.creation_time))

        # Remove old circuits
        old_circuits = [circuit_id for circuit_id in self.circuit_to_listindex if circuit_id not in self.circuits]
        for circuit_id in old_circuits:
            listindex = self.circuit_to_listindex[circuit_id]
            self.circuit_list.DeleteItem(listindex)
            self.circuit_to_listindex.pop(circuit_id)
            for k, v in self.circuit_to_listindex.items():
                if v > listindex:
                    self.circuit_to_listindex[k] = v - 1

        self.graph_panel.Refresh()
示例#7
0
def print_info(dispersy):
    stats = dispersy.statistics
    print >> sys.stderr, u"\n\n===== Dispersy Info ====="
    print >> sys.stderr, u"- WAN Address %s:%d" % stats.wan_address
    print >> sys.stderr, u"- LAN Address %s:%d" % stats.lan_address
    print >> sys.stderr, u"- Connection: %s" % unicode(stats.connection_type)
    print >> sys.stderr, u"- Runtime: %s" % eta_value(stats.timestamp - stats.start)
    print >> sys.stderr, u"- Download: %s or %s/s" % (size_format(stats.total_down),
                                                      size_format(int(stats.total_down / (stats.timestamp - stats.start))))
    print >> sys.stderr, u"- Upload: %s or %s/s" % (size_format(stats.total_up),
                                                    size_format(int(stats.total_up / (stats.timestamp - stats.start))))
    print >> sys.stderr, u"- Packets Sent: %s" % compute_ratio(stats.total_send,
                                                               stats.total_received + stats.total_send)
    print >> sys.stderr, u"- Packets Received: %s" % compute_ratio(stats.total_received,
                                                                   stats.total_received + stats.total_send)
    print >> sys.stderr, u"- Packets Success: %s" % compute_ratio(stats.msg_statistics.success_count,
                                                                  stats.total_received)
    print >> sys.stderr, u"- Packets Dropped: %s" % compute_ratio(stats.msg_statistics.drop_count, stats.total_received)
    print >> sys.stderr, u"- Packets Delayed: %s" % compute_ratio(stats.msg_statistics.delay_received_count,
                                                                  stats.total_received)
    print >> sys.stderr, u"- Packets Delayed send: %s" % compute_ratio(stats.msg_statistics.delay_send_count,
                                                                       stats.msg_statistics.delay_received_count)
    print >> sys.stderr, u"- Packets Delayed success: %s" % compute_ratio(stats.msg_statistics.delay_success_count,
                                                                          stats.msg_statistics.delay_received_count)
    print >> sys.stderr, u"- Packets Delayed timeout: %s" % compute_ratio(stats.msg_statistics.delay_timeout_count,
                                                                          stats.msg_statistics.delay_received_count)
    print >> sys.stderr, u"- Walker Success: %s" % compute_ratio(stats.walk_success_count, stats.walk_attempt_count)
    print >> sys.stderr, u"- Sync-Messages Created: %s" % stats.msg_statistics.created_count
    print >> sys.stderr, u"- Bloom New: %s" % compute_ratio(sum(c.sync_bloom_new for c in stats.communities),
                                                            sum(c.sync_bloom_send + c.sync_bloom_skip
                                                                for c in stats.communities))
    print >> sys.stderr, u"- Bloom Reused: %s" % compute_ratio(sum(c.sync_bloom_reuse for c in stats.communities),
                                                               sum(c.sync_bloom_send + c.sync_bloom_skip
                                                                   for c in stats.communities))
    print >> sys.stderr, u"- Bloom Skipped: %s" % compute_ratio(sum(c.sync_bloom_skip for c in stats.communities),
                                                                sum(c.sync_bloom_send + c.sync_bloom_skip
                                                                    for c in stats.communities))
    print >> sys.stderr, u"- Debug Mode: %s" % u"yes" if __debug__ else u"no"
    print >> sys.stderr, u"====================\n\n"
示例#8
0
 def RefreshFreeSpace(self, space):
     if space >= 0:
         space_str = size_format(space, truncate=1)
         space_label = space_str.replace(' ', '')
         space_tooltip = 'You currently have %s of disk space available on your default download location.' % space_str
         self.free_space.SetLabel(space_label)
         self.free_space.SetToolTipString(space_tooltip)
         self.free_space.Show(True)
         self.free_space_sbmp.SetToolTipString(space_tooltip)
         self.free_space_sbmp.Show(True)
     else:
         self.free_space.Show(False)
         self.free_space_sbmp.Show(False)
     self.Reposition()
示例#9
0
文件: SaveAs.py 项目: Azzhag/tribler
    def AddFileList(self, tdef, selectedFiles, vSizer, index):
        self.listCtrl = CheckSelectableListCtrl(self)
        self.listCtrl.InsertColumn(0, 'Name')
        self.listCtrl.InsertColumn(1, 'Size', wx.LIST_FORMAT_RIGHT)

        # Add files
        def sort_by_size(a, b):
            return cmp(a[1], b[1])

        files = tdef.get_files_as_unicode_with_length()
        files.sort(sort_by_size, reverse=True)

        for filename, size in files:
            try:
                pos = self.listCtrl.InsertStringItem(sys.maxsize, filename)
            except:
                try:
                    pos = self.listCtrl.InsertStringItem(sys.maxsize, filename.decode('utf-8', 'ignore'))
                except:
                    self._logger.error("Could not format filename %s", self.torrent.name)
            self.listCtrl.SetItemData(pos, pos)
            self.listCtrl.SetStringItem(pos, 1, size_format(size))

            if selectedFiles:
                self.listCtrl.CheckItem(pos, filename in selectedFiles)

        if selectedFiles is None:
            self.listCtrl.doSelectAll()

        self.listCtrl.setResizeColumn(0)
        self.listCtrl.SetColumnWidth(1, wx.LIST_AUTOSIZE)  # autosize only works after adding rows
        vSizer.Insert(index, self.listCtrl, 1, wx.EXPAND | wx.BOTTOM, 3)

        self.listCtrl.SetFocus()

        def OnChar(event):
            if event.GetKeyCode() == wx.WXK_RETURN:
                self.OnOk()
            else:
                event.Skip()
        self.listCtrl.Bind(wx.EVT_CHAR, OnChar)

        vSizer.Insert(index, wx.StaticText(
            self, -1, 'Use the checkboxes to choose which files to download.\nUse ctrl+a to select all/deselect all.'), 0, wx.BOTTOM, 3)

        firstLine = wx.StaticText(self, -1, "Content:")
        _set_font(firstLine, fontweight=wx.FONTWEIGHT_BOLD)
        vSizer.Insert(index, firstLine, 0, wx.BOTTOM, 3)

        vSizer.Insert(index, wx.StaticLine(self, -1), 0, wx.EXPAND | wx.BOTTOM, 10)
示例#10
0
    def _UpdateStats(self, stats, nr_channels):
        self.nrTorrents.SetLabel(str(stats[0]))
        if stats[1] is None:
            self.totalSize.SetLabel(str(stats[1]))
        else:
            self.totalSize.SetLabel(size_format(stats[1]))
        self.nrFiles.SetLabel(str(stats[2]))
        self.queueSize.SetLabel(self.remotetorrenthandler.getQueueSize())
        self.queueBW.SetLabel(self.remotetorrenthandler.getBandwidthSpent())

        qsuccess = self.remotetorrenthandler.getQueueSuccess()
        qlabel = ", ".join(label for label, tooltip in qsuccess)
        qtooltip = ", ".join(tooltip for label, tooltip in qsuccess)
        self.queueSuccess.SetLabel(qlabel)
        self.queueSuccess.SetToolTipString(qtooltip)
        self.nrChannels.SetLabel(str(nr_channels))

        if self.freeMem:
            self.freeMem.SetLabel(size_format(wx.GetFreeMemory()))

        if self.timer:
            self.timer.Restart(10000)
        else:
            self.timer = wx.CallLater(10000, self.UpdateStats)
示例#11
0
文件: home.py 项目: Antiade/tribler
    def _UpdateStats(self, stats, nr_channels):
        self.nrTorrents.SetLabel(str(stats[0]))
        if stats[1] is None:
            self.totalSize.SetLabel(str(stats[1]))
        else:
            self.totalSize.SetLabel(size_format(stats[1]))
        self.nrFiles.SetLabel(str(stats[2]))
        self.queueSize.SetLabel(self.remotetorrenthandler.getQueueSize())
        self.queueBW.SetLabel(self.remotetorrenthandler.getBandwidthSpent())

        qsuccess = self.remotetorrenthandler.getQueueSuccess()
        qlabel = ", ".join(label for label, tooltip in qsuccess)
        qtooltip = ", ".join(tooltip for label, tooltip in qsuccess)
        self.queueSuccess.SetLabel(qlabel)
        self.queueSuccess.SetToolTipString(qtooltip)
        self.nrChannels.SetLabel(str(nr_channels))

        if self.freeMem:
            self.freeMem.SetLabel(size_format(wx.GetFreeMemory()))

        if self.timer:
            self.timer.Restart(10000)
        else:
            self.timer = wx.CallLater(10000, self.UpdateStats)
示例#12
0
 def RefreshFreeSpace(self, space):
     if space >= 0:
         space_str = size_format(space, truncate=1)
         space_label = space_str.replace(' ', '')
         space_tooltip = 'You currently have %s of disk space available on your default download location.' % space_str
         self.free_space.SetLabel(space_label)
         self.free_space.Show(True)
         self.free_space_sbmp.Show(True)
         # TODO martijn: we disabled some tooltips that are periodically updated on OS X.
         # There seems to be a bug (in wx3) where the tooltip would always show when being updated.
         if sys.platform != 'darwin':
             self.free_space_sbmp.SetToolTipString(space_tooltip)
             self.free_space.SetToolTipString(space_tooltip)
     else:
         self.free_space.Show(False)
         self.free_space_sbmp.Show(False)
     self.Reposition()
示例#13
0
 def test_size_format_giga_bytes(self):
     result = size_format(123 * GB)
     self.assertEqual("123.00 GB", result)
示例#14
0
 def test_size_format_terra_bytes(self):
     result = size_format(123 * TB)
     self.assertEqual("123.00 TB", result)
示例#15
0
 def test_size_format_bytes_textonly(self):
     # this one is an odd one out, the textonly option returns Byte as unit instead of B
     result = size_format(123, textonly=True, showbytes=True)
     self.assertEqual("Byte", result)
示例#16
0
 def test_size_format_bytes_showbytes(self):
     result = size_format(123, showbytes=True)
     self.assertEqual("123 B", result)
示例#17
0
 def test_size_format_negative(self):
     result = size_format(-123 * MB)
     self.assertEqual("-123.00 MB", result)
示例#18
0
 def test_size_format_kilo_bytes(self):
     result = size_format(123 * KB)
     self.assertEqual("123.00 KB", result)
示例#19
0
 def test_size_format_terra_bytes_stopearly_gb(self):
     result = size_format(123 * TB, stopearly="GB")
     self.assertEqual("125952.00 GB", result)
示例#20
0
 def test_size_format_giga_bytes_no_label(self):
     result = size_format(123.123 * GB, applylabel=False)
     self.assertEqual("123.12", result)
示例#21
0
 def test_size_format_kilo_bytes_textonly(self):
     result = size_format(123 * KB, textonly=True)
     self.assertEqual("KB", result)
示例#22
0
 def test_size_format_terra_bytes_stopearly_byte(self):
     result = size_format(123 * TB, stopearly="Byte")
     self.assertEqual("135239930216448 B", result)
示例#23
0
 def test_size_format_kilo_bytes_labelonly_showbytes(self):
     result = size_format(123 * KB, labelonly=True, showbytes=True)
     self.assertEqual("KB", result)
示例#24
0
 def test_size_format_bytes_textonly_showbytes(self):
     result = size_format(123, textonly=True, showbytes=True)
     self.assertEqual("Byte", result)
示例#25
0
 def test_size_format_kilo_bytes_showbytes(self):
     result = size_format(123 * KB, showbytes=True)
     # This might not be what one expects, however currently the input has to be smaller than KB to show as bytes
     self.assertEqual("123.00 KB", result)
示例#26
0
 def test_size_format_mega_bytes(self):
     result = size_format(123 * MB)
     self.assertEqual("123.00 MB", result)
示例#27
0
 def test_size_format_bytes_size(self):
     result = size_format(123, rawsize=True, showbytes=True)
     self.assertEqual(123, result)
示例#28
0
 def test_size_format_mega_bytes_size(self):
     result = size_format(123 * MB, rawsize=True)
     self.assertEqual(123, result)
示例#29
0
 def test_size_format_bytes(self):
     result = size_format(123)
     self.assertEqual("0.12 KB", result)
示例#30
0
 def SetTunnelContrib(self, totalcontrib, netcontrib):
     self.tunnel_contrib.SetLabel('Total: %s' %
                                  size_format(totalcontrib, truncate=2))
     self.tunnel_contribNet.SetLabel('Balance: %s' %
                                     size_format(netcontrib, truncate=2))
     self.Reposition()
示例#31
0
 def test_size_format_terra_bytes_stopearly_kb(self):
     result = size_format(123 * TB, stopearly="KB")
     self.assertEqual("132070244352.00 KB", result)
示例#32
0
 def test_size_format_bytes_labelonly(self):
     # this one is regular again as opposed to the textonly version
     result = size_format(123, labelonly=True, showbytes=True)
     self.assertEqual("B", result)
示例#33
0
 def test_size_format_terra_bytes_stopearly_mb(self):
     result = size_format(123 * TB, stopearly="MB")
     self.assertEqual("128974848.00 MB", result)
示例#34
0
 def test_size_format_giga_bytes_truncate_2(self):
     result = size_format(123.123 * GB, truncate=2)
     self.assertEqual("123.12 GB", result)