예제 #1
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")
예제 #2
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")
예제 #3
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
예제 #4
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