Beispiel #1
0
def forceNZBParRecover(nzb):
    """ Immediately begin (force) downloading recovery blocks (only the nzb.neededBlocks
    amount) for the specified NZB """
    nzb.isParRecovery = True

    if not len(Hellanzb.nzbQueue) and not len(Hellanzb.queue.currentNZBs()):
        new = os.path.join(Hellanzb.CURRENT_DIR, os.path.basename(nzb.nzbFileName))
        move(nzb.nzbFileName, new)
        nzb.nzbFileName = new

        # FIXME: Would be nice to include the number of needed recovery blocks in the
        # growl notification this triggers
        if Hellanzb.downloadScannerID is not None and \
                not Hellanzb.downloadScannerID.cancelled and \
                not Hellanzb.downloadScannerID.called:
            Hellanzb.downloadScannerID.cancel()

        nzb.destDir = Hellanzb.WORKING_DIR
        parseNZB(nzb, 'Downloading recovery pars')
    else:
        Hellanzb.nzbQueue.insert(0, nzb)
        forceNZB(nzb.nzbFileName, 'Forcing par recovery download')
Beispiel #2
0
def forceNZB(nzbfilename, notification="Forcing download"):
    """ Interrupt the current download, if necessary, to start the specified nzb """
    if not validNZB(nzbfilename):
        return

    if not len(Hellanzb.queue.nzbs):
        # No need to actually 'force'
        from Hellanzb.NZBLeecher.NZBModel import NZB

        return parseNZB(NZB(nzbfilename))

    # postpone the current NZB download
    for nzb in Hellanzb.queue.currentNZBs():
        try:
            info("Interrupting: " + nzb.archiveName)
            nzb.postpone()

            # remove what we've forced with from the old queue, if it exists
            nzb = None
            for n in Hellanzb.nzbQueue:
                if os.path.normpath(n.nzbFileName) == os.path.normpath(nzbfilename):
                    nzb = n

            if nzb is None:
                from Hellanzb.NZBLeecher.NZBModel import NZB

                nzb = NZB(nzbfilename)
            else:
                Hellanzb.nzbQueue.remove(nzb)

            # Copy the specified NZB, unless it's already in the queue dir (move it
            # instead)
            if os.path.normpath(os.path.dirname(nzbfilename)) != os.path.normpath(Hellanzb.QUEUE_DIR):
                copy(nzbfilename, os.path.join(Hellanzb.CURRENT_DIR, os.path.basename(nzbfilename)))
            else:
                move(nzbfilename, os.path.join(Hellanzb.CURRENT_DIR, os.path.basename(nzbfilename)))
            nzbfilename = os.path.join(Hellanzb.CURRENT_DIR, os.path.basename(nzbfilename))
            nzb.nzbFileName = nzbfilename

            # delete everything from the queue. priority will be reset
            Hellanzb.queue.postpone()

            # load the new file
            reactor.callLater(0, parseNZB, nzb, notification)

        except NameError, ne:
            # GC beat us. that should mean there is either a free spot open, or the next
            # nzb in the queue needs to be interrupted????
            debug("forceNZB: NAME ERROR", ne)
            reactor.callLater(0, scanQueueDir)
Beispiel #3
0
def forceNZB(nzbfilename, notification='Forcing download'):
    """ Interrupt the current download, if necessary, to start the specified nzb """
    if not validNZB(nzbfilename):
        return

    if not len(Hellanzb.queue.nzbs):
        # No need to actually 'force'
        from Hellanzb.NZBLeecher.NZBModel import NZB
        return parseNZB(NZB(nzbfilename))

    # postpone the current NZB download
    for nzb in Hellanzb.queue.currentNZBs():
        try:
            info('Interrupting: ' + nzb.archiveName)
            nzb.postpone()

            # remove what we've forced with from the old queue, if it exists
            nzb = None
            for n in Hellanzb.nzbQueue:
                if os.path.normpath(n.nzbFileName) == os.path.normpath(nzbfilename):
                    nzb = n
                    
            if nzb is None:
                from Hellanzb.NZBLeecher.NZBModel import NZB
                nzb = NZB(nzbfilename)
            else:
                Hellanzb.nzbQueue.remove(nzb)
    
            # Copy the specified NZB, unless it's already in the queue dir (move it
            # instead)
            if os.path.normpath(os.path.dirname(nzbfilename)) != os.path.normpath(Hellanzb.QUEUE_DIR):
                copy(nzbfilename, os.path.join(Hellanzb.CURRENT_DIR, os.path.basename(nzbfilename)))
            else:
                move(nzbfilename, os.path.join(Hellanzb.CURRENT_DIR, os.path.basename(nzbfilename)))
            nzbfilename = os.path.join(Hellanzb.CURRENT_DIR, os.path.basename(nzbfilename))
            nzb.nzbFileName = nzbfilename

            # delete everything from the queue. priority will be reset
            Hellanzb.queue.postpone()

            # load the new file
            reactor.callLater(0, parseNZB, nzb, notification)

        except NameError, ne:
            # GC beat us. that should mean there is either a free spot open, or the next
            # nzb in the queue needs to be interrupted????
            debug('forceNZB: NAME ERROR', ne)
            reactor.callLater(0, scanQueueDir)