Beispiel #1
0
    def test_sleep(self):
        args = ['sleep', '3000']
        proc = Process(args)

        #Test the command ran without problem
        self.assertEqual(proc.poll(), None)

        #Test killing
        proc.kill()

        #Test poll returns now
        self.assertTrue(proc.poll() is not None)
Beispiel #2
0
    def startExtract(self, filePath, trackID):
        self.progress = 0
        extractPath = os.path.join(self.toolsDir, "mkvextract")
        self.outPath = os.path.splitext(filePath)[0] + self.trackExt
        args = [
            extractPath, "tracks", filePath,
            str(trackID) + ':' + self.outPath
        ]
        log('executing args: %s' % args)

        self.proc = Process(args)
        self.mThread = self.proc.start_monitor_thread(self._ReadProgress,
                                                      self._FinishExtract)
Beispiel #3
0
    def test_get_output(self):
        args = ['python', 'PrintNumExec.py', '10']
        proc = Process(args)

        #Test the command ran without problem
        self.assertEqual(proc.poll(), None)

        proc.wait()

        for i, line in enumerate(proc.get_outlines()):
            self.assertEqual(line, "%d\n" % (i + 1))
            lastline = line

        self.assertTrue(proc.poll() is not None)
        self.assertEqual(lastline, "10\n")
Beispiel #4
0
    def test_pipe_output(self):
        args = ['python', 'PrintNumExec.py', '12']
        proc = Process(args)

        #Test the command ran without problem
        self.assertEqual(proc.poll(), None)

        self.lastLine = None
        self.finished = False
        mThread = proc.start_monitor_thread(self._ReadProgress,
                                            self._FinishExtract)

        mThread.join()

        self.assertTrue(self.finished)
        self.assertEqual(self.lastLine, "12\n")
Beispiel #5
0
    def getSubTrack(self, filePath):
        """Uses mkvinfo to find the track that contains the subtitles"""
        infoPath = os.path.join(self.toolsDir, "mkvinfo")
        log('path to executable mkvinfo: %s' % infoPath)
        log('path of file to check %s' % filePath)
        proc = Process([infoPath, filePath])
        proc.wait()
        output = proc.get_outlines()
        log('output was %s' % output)
        log('Result was %d' % proc.poll())

        tracks = {}
        trackNumber = None
        for line in output:
            r = re.search('[+] Track number: (\d+)', line)
            if r:
                trackNumber = int(r.group(1))
                trackID = trackNumber
                r = re.search('track ID .*: (\d+)', line)
                if r:
                    trackID = int(r.group(1))
                tracks[trackNumber] = {'TID': trackID}
                continue

            r = re.search('[+] Track type: (.+)', line)
            if r:
                trackType = r.group(1)
                tracks[trackNumber]['type'] = trackType
                continue

            r = re.search('[+] Language: (.+)', line)
            if r:
                language = r.group(1)
                tracks[trackNumber]['language'] = language
                continue

            r = re.search('[+] Codec ID: (.+)', line)
            if r:
                codec = r.group(1)
                tracks[trackNumber]['codec'] = codec
                continue

        subTrackID = None
        for track in tracks.values():
            if track['type'] != 'subtitles':
                continue
            if 'language' in track and track['language'] != 'eng':
                continue
            if 'codec' in track and track['codec'] == 'S_TEXT/SSA':
                subTrackID = track['TID']
                self.trackExt = '.ssa'
                continue  # keep looking for srt
            if 'codec' in track and track['codec'] == 'S_TEXT/ASS':
                subTrackID = track['TID']
                self.trackExt = '.ass'
                continue  # keep looking for srt
            if 'codec' in track and track['codec'] == 'S_TEXT/UTF8':
                subTrackID = track['TID']
                self.trackExt = ".srt"
                break  # srt trumps other formats

        return subTrackID