コード例 #1
0
    def RefreshTransferSpeed(self, dslist, magnetlist):
        if not self:
            return

        self.UpdateTunnelContrib()
        total_down, total_up = get_download_upload_speed(dslist)
        self.SetTransferSpeeds(speed_format(total_down),
                               speed_format(total_up))
コード例 #2
0
 def test_speed_format_none(self):
     result = speed_format(None)
     self.assertEqual("", result)
コード例 #3
0
 def test_speed_format_more_terra_bytes(self):
     result = speed_format(123 * TB)
     self.assertEqual("123.0 TB/s", result)
コード例 #4
0
 def test_speed_format_terra_byte(self):
     result = speed_format(12 * TB)
     self.assertEqual("12.0 TB/s", result)
コード例 #5
0
 def test_speed_format_almost_terra_byte(self):
     result = speed_format(1 * TB - 2 * GB)
     self.assertEqual("1.0 TB/s", result)
コード例 #6
0
 def test_speed_format_more_giga_bytes(self):
     result = speed_format(123 * GB)
     self.assertEqual("123 GB/s", result)
コード例 #7
0
 def test_speed_format_giga_byte(self):
     result = speed_format(12 * GB)
     self.assertEqual("12.0 GB/s", result)
コード例 #8
0
    def __init__(self, parent):
        wx.StatusBar.__init__(self, parent, style=wx.ST_SIZEGRIP)

        self._gui_image_manager = GuiImageManager.getInstance()

        self.guiutility = GUIUtility.getInstance()
        self.utility = self.guiutility.utility
        self.library_manager = self.guiutility.library_manager

        self.ff_checkbox = wx.CheckBox(self,
                                       -1,
                                       'Family filter',
                                       style=wx.ALIGN_RIGHT)
        self.ff_checkbox.Bind(wx.EVT_CHECKBOX, self.OnCheckbox)
        self.ff_checkbox.SetValue(self.guiutility.getFamilyFilter())

        self.tunnel_contrib = wx.StaticText(self, -1, '')
        self.tunnel_contrib.SetToolTipString('Total Anonymity Contribution')
        self.tunnel_contribNet = wx.StaticText(self, -1, '')
        self.tunnel_contribNet.SetToolTipString(
            'Anonymity Contribution Balance')

        self.speed_down_icon = self._gui_image_manager.getBitmap(
            self, u"arrow", self.GetBackgroundColour(), state=0)
        self.speed_down_sbmp = wx.StaticBitmap(self, -1, self.speed_down_icon)
        self.speed_down_sbmp.Bind(wx.EVT_RIGHT_UP, self.OnDownloadPopup)
        self.speed_down = wx.StaticText(self, -1, '')
        self.speed_down.Bind(wx.EVT_RIGHT_UP, self.OnDownloadPopup)

        self.speed_up_icon = self.speed_down_icon.ConvertToImage().Rotate90(
        ).Rotate90().ConvertToBitmap()
        self.speed_up_sbmp = wx.StaticBitmap(self, -1, self.speed_up_icon)
        self.speed_up_sbmp.Bind(wx.EVT_RIGHT_UP, self.OnUploadPopup)
        self.speed_up = wx.StaticText(self, -1, '')
        self.speed_up.Bind(wx.EVT_RIGHT_UP, self.OnUploadPopup)

        self.free_space_icon = self._gui_image_manager.getImage(u"drive.png")
        self.free_space_sbmp = wx.StaticBitmap(self, -1, self.free_space_icon)
        self.free_space = wx.StaticText(self, -1, '')

        self.searchConnectionImages = [
            u"progressbarEmpty.png", u"progressbarFull.png"
        ]
        self.searchConnectionImages = [
            self._gui_image_manager.getImage(image)
            for image in self.searchConnectionImages
        ]

        self.activityImages = [
            u"statusbar_activity.png", u"statusbar_noactivity.png"
        ]
        self.activityImages = [
            self._gui_image_manager.getImage(image)
            for image in self.activityImages
        ]

        self.connection = HorizontalGauge(self, self.searchConnectionImages[0],
                                          self.searchConnectionImages[1])
        self.connection.SetBackgroundColour(self.GetBackgroundColour())
        self.activity = wx.StaticBitmap(self, -1, self.activityImages[1])
        self.activity_timer = None
        self.channelconnections = 0

        self.bmp_firewall_warning = self._gui_image_manager.getImage(
            u"statusbar_warning.png")
        self.bmp_firewall_ok = self._gui_image_manager.getImage(
            u"statusbar_ok.png")
        self.firewallStatus = ActionButton(self, -1, self.bmp_firewall_warning)
        self.firewallStatus.SetSize((16, 16))
        self.firewallStatus.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))
        self.firewallStatus.SetToolTipString('Port status unknown')
        self.firewallStatus.Enable(False)
        self.firewallStatus.SetBitmapDisabled(self.bmp_firewall_warning)

        # On Linux/OS X the resize handle and icons overlap, therefore we add an extra field.
        # On Windows this field is automatically set to 1 when the wx.ST_SIZEGRIP (parent class constructor) is set.
        self.fields = [
            (-1, wx.SB_FLAT, [self.ff_checkbox]),
            (100, wx.SB_FLAT, [self.tunnel_contrib, self.tunnel_contribNet]),
            (200, wx.SB_FLAT, [
                self.speed_down_sbmp, self.speed_down, self.speed_up_sbmp,
                self.speed_up
            ]), (75, wx.SB_FLAT, [self.free_space_sbmp, self.free_space]),
            (19, wx.SB_FLAT, [self.connection]),
            (19, wx.SB_FLAT, [self.activity]),
            (19, wx.SB_FLAT, [self.firewallStatus])
        ]

        if sys.platform != "win32":
            self.fields.append((19, wx.SB_FLAT, []))

        self.SetFieldsCount(len(self.fields))
        self.SetStatusWidths([field[0] for field in self.fields])
        self.SetStatusStyles([field[1] for field in self.fields])

        self.SetTransferSpeeds(speed_format(0), speed_format(0))
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.library_manager.add_download_state_callback(
            self.RefreshTransferSpeed)
コード例 #9
0
 def test_speed_format_more_mega_bytes(self):
     result = speed_format(123 * MB)
     self.assertEqual("123 MB/s", result)
コード例 #10
0
 def test_speed_format_mega_byte(self):
     result = speed_format(12 * MB)
     self.assertEqual("12.0 MB/s", result)
コード例 #11
0
 def test_speed_format_almost_mega_byte(self):
     result = speed_format(1 * MB - 2 * KB)
     self.assertEqual("1.0 MB/s", result)
コード例 #12
0
 def test_speed_format_more_kilo_bytes(self):
     result = speed_format(123 * KB)
     self.assertEqual("123 KB/s", result)
コード例 #13
0
 def test_speed_format_bytes(self):
     result = speed_format(Unit * 0.5)
     self.assertEqual("0.5 KB/s", result)
コード例 #14
0
 def updateTooltip(self, download_speed=0, upload_speed=0):
     if not WIN32:
         return
     self.tooltip = "Down: %s, Up: %s" % (speed_format(download_speed),
                                          speed_format(upload_speed))
     self.SetIcon(self.icon, self.tooltip)
コード例 #15
0
 def test_speed_format_negative_mega_byte(self):
     result = speed_format(-12 * MB)
     self.assertEqual("-12.0 MB/s", result)
コード例 #16
0
ファイル: SRstatusbar.py プロジェクト: yorig/tribler
 def SetTransferSpeeds(self, down, up):
     self.speed_down.SetLabel(speed_format(down))
     self.speed_up.SetLabel(speed_format(up))
     self.Reposition()
コード例 #17
0
 def test_speed_format_almost_giga_byte(self):
     result = speed_format(1 * GB - 2 * MB)
     self.assertEqual("1.0 GB/s", result)