<commit_before>"""

PostProcessor (aka troll) - verify/repair/unarchive/decompress files downloaded with
nzbget

(c) Copyright 2005 <NAME>, <NAME>
[See end of file]
"""
import Hellanzb, os, re, sys, time
from os.path import join as pathjoin
from shutil import rmtree
from threading import Thread, Condition, Lock
from Hellanzb.Log import *
from Hellanzb.PostProcessorUtil import *
from Hellanzb.Util import *

__id__ = '$Id$'

class PostProcessor(Thread):
    """ A post processor (formerly troll) instance runs in its own thread """
    dirName = None
    decompressionThreadPool = None
    decompressorCondition = None
    background = None
    musicFiles = None
    brokenFiles = None

    failedLock = None
    failedToProcesses = None
    
    msgId = None
    nzbFile = None

    def __init__(self, dirName, background = True, rarPassword = None, parentDir = None):
        """ Ensure sanity of this instance before starting """
        # abort if we lack required binaries
        assertIsExe('par2')
        
        self.dirName = os.path.realpath(dirName)
        self.dirName = DirName(self.dirName)
        
        # Whether or not this thread is the only thing happening in the app (-p mode)
        self.background = background
        
        self.decompressionThreadPool = []
        self.decompressorLock = Lock()
        self.decompressorCondition = Condition(self.decompressorLock)

        self.rarPassword = <PASSWORD>

        # The parent directory we the originating post process call started from, if we
        # are post processing a sub directory
        self.isSubDir = False
        self.parentDir = parentDir
        if self.parentDir != None:
            self.isSubDir = True
            self.dirName.parentDir = self.parentDir
            
        self.startTime = None
    
        Thread.__init__(self)

    def addDecompressor(self, decompressorThread):
        """ Add a decompressor thread to the pool and notify the caller """
        self.decompressorCondition.acquire()<commit_msg>rumble found out the hard way that the post processor decompressorLock must be re-entrant. I didn't think it had to be, serves me right for fucking with it. shouts to rumble<commit_after>"""

PostProcessor (aka troll) - verify/repair/unarchive/decompress files downloaded with
nzbget

(c) Copyright 2005 <NAME>, <NAME>
[See end of file]
"""
import Hellanzb, os, re, sys, time
from os.path import join as pathjoin
from shutil import rmtree
from threading import Thread, Condition, Lock, RLock
from Hellanzb.Log import *
from Hellanzb.PostProcessorUtil import *
from Hellanzb.Util import *

__id__ = '$Id$'

class PostProcessor(Thread):
    """ A post processor (formerly troll) instance runs in its own thread """
    dirName = None
    decompressionThreadPool = None
    decompressorCondition = None
    background = None
    musicFiles = None
    brokenFiles = None

    failedLock = None
    failedToProcesses = None
    
    msgId = None
    nzbFile = None

    def __init__(self, dirName, background = True, rarPassword = None, parentDir = None):
        """ Ensure sanity of this instance before starting """
        # abort if we lack required binaries
        assertIsExe('par2')
        
        self.dirName = os.path.realpath(dirName)
        self.dirName = DirName(self.dirName)
        
        # Whether or not this thread is the only thing happening in the app (-p mode)
        self.background = background
        
        self.decompressionThreadPool = []
        self.decompressorLock = RLock()
        self.decompressorCondition = Condition(self.decompressorLock)

        self.rarPassword = rarPassword

        # The parent directory we the originating post process call started from, if we
        # are post processing a sub directory
        self.isSubDir = False
        self.parentDir = parentDir
        if self.parentDir != None:
            self.isSubDir = True
            self.dirName.parentDir = self.parentDir
            
        self.startTime = None
    
        Thread.__init__(self)

    def addDecompressor(self, decompressorThread):
        """ Add a decompressor thread to the pool and notify the caller """
        self.decompressorCondition.acquire()
{'fraction_non_alphanumeric': 0.07398624614654968, 'fraction_numerical': 0.0023713540431586438, 'mean_word_length': 2.7097625329815305, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2940376', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1130, 'n_words': 396}