⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abcengine.py

📁 BitTorrentABC-Linux-V.2.4.3源码
💻 PY
📖 第 1 页 / 共 2 页
字号:
                if self.dow.storagewrapper is not None:
                    self.detailwin.storagestats1.SetLabel(
                        '          currently downloading %d pieces (%d just started), %d pieces partially retrieved'
                                        % ( len(self.dow.storagewrapper.stat_active),
                                            len(self.dow.storagewrapper.stat_new),
                                            len(self.dow.storagewrapper.dirty)  ) )
                    self.detailwin.storagestats2.SetLabel(
                        '          %d of %d pieces complete (%d just downloaded), %d failed hash check'
                                        % ( self.dow.storagewrapper.stat_numfound +
                                            self.dow.storagewrapper.stat_numdownloaded,
                                            len(self.dow.storagewrapper.hashes),
                                            self.dow.storagewrapper.stat_numdownloaded,
                                            self.dow.storagewrapper.stat_numflunked ) )



                if spew is not None and (time() - self.spewwait > 1):
                    self.spewwait = time()
                    spewList = self.detailwin.spewList
                    if (spewList.GetItemCount()-len(spew)) < 0:
                        for x in range(len(spew)-spewList.GetItemCount()):
                            spewList.InsertStringItem(x,'')
                    if (spewList.GetItemCount()-len(spew)) > 0:
                        for x in range(spewList.GetItemCount()-len(spew)):
                            spewList.SetStringItem((len(spew))+x, 0, '')
                            spewList.SetStringItem((len(spew))+x, 1, '')
                            spewList.SetStringItem((len(spew))+x, 2, '')
                            spewList.SetStringItem((len(spew))+x, 3, '')
                            spewList.SetStringItem((len(spew))+x, 4, '')
                            spewList.SetStringItem((len(spew))+x, 5, '')
                            spewList.SetStringItem((len(spew))+x, 6, '')
                            spewList.SetStringItem((len(spew))+x, 7, '')
                            spewList.SetStringItem((len(spew))+x, 8, '')
                            spewList.SetStringItem((len(spew))+x, 9, '')
                            spewList.SetStringItem((len(spew))+x, 10, '')
                            spewList.SetStringItem((len(spew))+x, 11, '')
                            spewList.SetStringItem((len(spew))+x, 12, '')
                            spewList.SetStringItem((len(spew))+x, 13, '')

                    for x in range(len(spew)):
                        if (spew[x]['optimistic'] == 1):
                            a = '*'
                        else:
                            a = ' '
                        spewList.SetStringItem(x, 0, a)
                        spewList.SetStringItem(x, 1, spew[x]['ip'])
                        spewList.SetStringItem(x, 2, spew[x]['direction'])
                        if spew[x]['uprate'] > 100:
                            spewList.SetStringItem(x, 3, '%.0f kB/s' % (float(spew[x]['uprate']) / 1000))
                        else:
                            spewList.SetStringItem(x, 3, '')
                        if (spew[x]['uinterested'] == 1):
                            a = '*'
                        else:
                            a = ' '
                        spewList.SetStringItem(x, 4, a)
                        if (spew[x]['uchoked'] == 1):
                            a = '*'
                        else:
                            a = ' '
                        spewList.SetStringItem(x, 5, a)
                        spewList.SetStringItem(x, 6, '%.0f kB/s' % (float(spew[x]['downrate']) / 1000))
                        if (spew[x]['dinterested'] == 1):
                            a = '*'
                        else:
                            a = ' '
                        spewList.SetStringItem(x, 7, a)
                        if (spew[x]['dchoked'] == 1):
                            a = '*'
                        else:
                            a = ' '
                        spewList.SetStringItem(x, 8, a)
                        if (spew[x]['snubbed'] == 1):
                            a = '*'
                        else:
                            a = ' '
                        spewList.SetStringItem(x, 9, a)
                        spewList.SetStringItem(x, 10, '%.2f MiB' % (float(spew[x]['dtotal']) / (1 << 20)))
                        spewList.SetStringItem(x, 11, '%.2f MiB' % (float(spew[x]['utotal']) / (1 << 20)))
                        spewList.SetStringItem(x, 12, '%.1f%%' % (float(int(spew[x]['completed']*1000)/10)))
                        spewList.SetStringItem(x, 13, '%.0f kB/s' % (float(spew[x]['speed']) / 1000))   
            if self.fin and int(self.parent.proctab[self.listid][10]) == 2 and self.shareratio >= float(self.parent.proctab[self.listid][13]):
                self.invokeLater(self.TerminateUpload)

            

    def finished(self):        
        self.fin = true
        self.invokeLater(self.onFinishEvent)
        
    def failed(self):
        self.fin = true
        if self.flag.isSet():
            self.onFailEvent()            
        else:
            self.invokeLater(self.onFailEvent)

    def error(self, errormsg):
        self.errormsg = strftime('%I:%M %p -') + errormsg
        self.errortxt = errormsg


    def TerminateUpload(self):
        # Terminate process
        ####################################################
        # change:   5:Progress  6:BT Status
        # untouch:  4:Title 7:Priority 9:Size 12:%U/DSize
        #           18:DownloadSize 19:UploadSize
        # clear : 8:ETA 10:DLSpeed 11:ULspeed 13:Error message
        #         14:#seed 15:#peer 16:#copie 17:peer avg
        #         20:total speed
        #####################################################
        for rank in range(0, self.guiman.getNumCol()):
            colid = self.guiman.getIDfromRank(rank)
            if colid == 4 or colid == 7 or colid == 9 or colid == 12 or colid == 18 or colid == 19:
                continue            
            elif colid == 5:   #progress
                self.list.SetStringItem(self.listid, rank, "100%")
            elif colid == 6:   #Status
                self.list.SetStringItem(self.listid, rank, "completed")
            else:
                self.list.SetStringItem(self.listid, rank, "")
                
        self.parent.procDONE(self.listid)

    def onFinishEvent(self):
        # seeding process
        ####################################################
        # change:   5:Progress  6:BT Status
        # untouch:  4:Title 7:Priority 9:Size 12:%U/DSize
        #           18:DownloadSize 19:UploadSize 11:ULspeed
        #           13:Error message
        #           14:#seed 15:#peer 16:#copie 17:peer avg
        #           20:total speed
        #
        # clear : 8:ETA 10:DLSpeed  
        #         
        #####################################################
        for rank in range(0, self.guiman.getNumCol()):
            colid = self.guiman.getIDfromRank(rank)
            if colid == 8 or colid == 10:
                self.list.SetStringItem(self.listid, rank, "")
            elif colid == 5:
                self.list.SetStringItem(self.listid, rank, "100%")
            elif colid == 6:
                self.list.SetStringItem(self.listid, rank, "completed/seeding")

        self.parent.procFINISH(self.listid)
        uploadopt = int(self.parent.proctab[self.listid][10])
        if uploadopt == 0:      #unlimited upload
            return
        elif uploadopt == 1:    #upload with timer
            uploadtimeh = self.parent.proctab[self.listid][11]
            uploadtimem = self.parent.proctab[self.listid][12]
            uploadtimes = (int(uploadtimeh)*3600) + (int(uploadtimem)*60)
            self.timer = Timer(uploadtimes, self.TerminateUpload)
            self.timer.start()
        else:                   #upload with ratio, must check at updatestatus also
            uploadratio = float(self.parent.proctab[self.listid][13])
            if self.shareratio >= uploadratio:
                self.invokeLater(self.TerminateUpload)
            
    def onFailEvent(self):
        
        #dlg = wxMessageDialog(self.parent.parent, self.errormsg + "\n this torrent will be deleted from list now"  , "Error!!", wxICON_ERROR)
        dlg = wxMessageDialog(self.parent.parent, self.errormsg + "\n\n This torrent will be set in pause state now"  , "Error!!", wxOK|wxICON_ERROR)
        if(dlg.ShowModal() == wxID_OK):
            dlg.Destroy()
        #self.parent.list.DeleteItem(self.listid)
        #self.parent.procREMOVE(self.listid)

            self.parent.procPAUSE(self.listid)
            for rank in range (0, self.guiman.getNumCol()):
                colid = self.guiman.getIDfromRank(rank)            
                if colid != 4 and colid != 7 and colid != 12 and colid != 18 and colid != 19:   
                    if colid == 6:              # change bt status to pause
                        self.list.SetStringItem(self.listid, rank, "pause")
                    else:
                        self.list.SetStringItem(self.listid, rank, "")

            
    def chooseFile(self, default, size, saveas, dir):
        if saveas != '':        #new proc set default folder or old proc active
            bucket = [None]
            self.filename = default
            self.totalsize = ('%.1f MB' % (float(size) / (1 << 20)))
            bucket[0] = saveas            
        return bucket[0]
    
    def newpath(self, path):
        self.fileDestPath = path

    def changeIndex(self, newindex):
        self.listid = newindex
    def changeDoneFlag(self, doneflag):
        self.flag = doneflag
    def changePrio(self, newprio):
        self.prio = newprio
        
    def done(self, event):
        self.flag.set()
        DELEVT_INVOKE(self)
        if self.timer != None :
            self.timer.cancel()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -