Exemplo n.º 1
0
    def xmlrpc_process(self, archiveDir, rarPassword=None):
        """ Post process the specified directory. The -p option is preferable -- it will do this
        for you, or use the current process if this XML-RPC call fails """
        # FIXME: merge this with Daemon.postProcess
        if not os.path.isdir(archiveDir):
            raise Fault(
                9001,
                'Unable to process, not a directory: ' + toUnicode(archiveDir))

        if not os.access(archiveDir, os.R_OK) or not os.access(
                archiveDir, os.W_OK):
            raise Fault(9001, 'Unable to process, no read/write access to directory: ' + \
                        toUnicode(archiveDir))

        dirName = os.path.dirname(archiveDir.rstrip(os.sep))
        # We are the queue daemon -- Symlink to the archiveDir. If we are ctrl-ced, we'll
        # pick up the post processing afterward restart
        if os.path.normpath(dirName) != os.path.normpath(
                Hellanzb.PROCESSING_DIR):
            destDir = dupeName(
                os.path.join(Hellanzb.PROCESSING_DIR,
                             os.path.basename(archiveDir.rstrip(os.sep))))
            # UNIX: symlink, windows =[
            os.symlink(archiveDir, destDir)
            archiveDir = destDir

        archive = Archive(archiveDir, rarPassword=rarPassword)
        troll = PostProcessor(archive)
        troll.start()
        return self.xmlrpc_status()