Logo Search packages:      
Sourcecode: hellanzb version File versions  Download package

def Hellanzb::NZBLeecher::ArticleDecoder::decode (   segment  ) 

Decode the NZBSegment's articleData to it's destination. Toggle the NZBSegment
instance as having been decoded, then assemble all the segments together if all their
decoded segment filenames exist 

Definition at line 25 of file ArticleDecoder.py.

00025                    :
    """ Decode the NZBSegment's articleData to it's destination. Toggle the NZBSegment
    instance as having been decoded, then assemble all the segments together if all their
    decoded segment filenames exist """
    encoding = UNKNOWN
    try:
        segment.loadArticleDataFromDisk()
        encoding = decodeArticleData(segment)
        
    except OutOfDiskSpace:
        # Ran out of disk space and the download was paused! Easiest way out of this
        # sticky situation is to requeue the segment
        nuke(segment.getDestination())
        segment.nzbFile.totalReadBytes -= segment.bytes
        segment.nzbFile.nzb.totalReadBytes -= segment.bytes
        reactor.callFromThread(Hellanzb.queue.put, (segment.priority, segment))
        return
    except Exception, e:
        if handleCanceledSegment(segment):
            # Cancelled NZBs could potentially cause IOErrors during writes -- just handle
            # cleanup and return
            return

        error(segment.nzbFile.showFilename + ' segment: ' + str(segment.number) + \
              ' a problem occurred during decoding', e)
        touch(segment.getDestination())

    if Hellanzb.SMART_PAR and segment.isFirstSegment():
        # This will dequeue all of this segment's sibling segments that are still in the
        # NZBSegmentQueue. Segments that aren't in the queue are either:
        # o already decoded and on disk
        # o currently downloading
        # Segments currently downloading are left in segment.nzbFile.todoNzbSegments
        segment.smartDequeue()
    
    Hellanzb.queue.segmentDone(segment)
    if Hellanzb.DEBUG_MODE_ENABLED:
        # FIXME: need a better enum
        if encoding == 1:
            encodingName = 'YENC'
        elif encoding == 2:
            encodingName = 'UUENCODE'
        else:
            encodingName = 'UNKNOWN'
        debug('Decoded (encoding: %s): %s' % (encodingName, segment.getDestination()))

    if handleCanceledSegment(segment):
        return

    if Hellanzb.SMART_PAR and segment.isFirstSegment() and \
            segment.nzbFile.nzb.firstSegmentsDownloaded == len(segment.nzbFile.nzb.nzbFiles):
        # Done downloading all first segments. Check for a few special situations that
        # warrant requeueing of files
        segment.nzbFile.nzb.smartRequeue()
        segment.nzbFile.nzb.logSkippedPars()

    tryAssemble(segment.nzbFile)

def tryAssemble(nzbFile):


Generated by  Doxygen 1.6.0   Back to index