Make packager_test.py work with python 3.5
Addresses binary/str conversion problems like 'can't use a string pattern on a bytes-like object'. With this change, packager_test.py will work with any version of python after python2.5. Fixes #553. Change-Id: I02066942e4bcdddc1db1daf761abab4cc46169a9
This commit is contained in:
parent
de534f8550
commit
57046be126
|
@ -45,11 +45,11 @@ class PackagerApp(object):
|
||||||
def DumpStreamInfo(self, stream):
|
def DumpStreamInfo(self, stream):
|
||||||
input_str = 'input=%s' % stream
|
input_str = 'input=%s' % stream
|
||||||
cmd = [self.packager_binary, input_str, '--dump_stream_info']
|
cmd = [self.packager_binary, input_str, '--dump_stream_info']
|
||||||
return subprocess.check_output(cmd, env=self.GetEnv())
|
return subprocess.check_output(cmd, env=self.GetEnv()).decode()
|
||||||
|
|
||||||
def Version(self):
|
def Version(self):
|
||||||
return subprocess.check_output(
|
return subprocess.check_output(
|
||||||
[self.packager_binary, '--version'], env=self.GetEnv())
|
[self.packager_binary, '--version'], env=self.GetEnv()).decode()
|
||||||
|
|
||||||
def Package(self, streams, flags=None):
|
def Package(self, streams, flags=None):
|
||||||
"""Executes packager command."""
|
"""Executes packager command."""
|
||||||
|
|
|
@ -173,7 +173,7 @@ def _UpdateMediaInfoPaths(media_info_filepath):
|
||||||
# after: media_file_name: "bear-640x360-audio.mp4"
|
# after: media_file_name: "bear-640x360-audio.mp4"
|
||||||
|
|
||||||
with open(media_info_filepath, 'rb') as f:
|
with open(media_info_filepath, 'rb') as f:
|
||||||
content = f.read()
|
content = f.read().decode()
|
||||||
|
|
||||||
regex = 'media_file_name: "(.*)"'
|
regex = 'media_file_name: "(.*)"'
|
||||||
for path in re.findall(regex, content):
|
for path in re.findall(regex, content):
|
||||||
|
@ -181,7 +181,7 @@ def _UpdateMediaInfoPaths(media_info_filepath):
|
||||||
content = content.replace(path, short_path)
|
content = content.replace(path, short_path)
|
||||||
|
|
||||||
with open(media_info_filepath, 'wb') as f:
|
with open(media_info_filepath, 'wb') as f:
|
||||||
f.write(content)
|
f.write(content.encode())
|
||||||
|
|
||||||
|
|
||||||
def _UpdateMpdTimes(mpd_filepath):
|
def _UpdateMpdTimes(mpd_filepath):
|
||||||
|
@ -200,7 +200,7 @@ def _UpdateMpdTimes(mpd_filepath):
|
||||||
return out
|
return out
|
||||||
|
|
||||||
with open(mpd_filepath, 'rb') as f:
|
with open(mpd_filepath, 'rb') as f:
|
||||||
content = f.read()
|
content = f.read().decode()
|
||||||
|
|
||||||
content = _Replace(
|
content = _Replace(
|
||||||
content,
|
content,
|
||||||
|
@ -213,7 +213,7 @@ def _UpdateMpdTimes(mpd_filepath):
|
||||||
'publishTime="some_time"')
|
'publishTime="some_time"')
|
||||||
|
|
||||||
with open(mpd_filepath, 'wb') as f:
|
with open(mpd_filepath, 'wb') as f:
|
||||||
f.write(content)
|
f.write(content.encode())
|
||||||
|
|
||||||
|
|
||||||
def GetExtension(input_file_path, output_format):
|
def GetExtension(input_file_path, output_format):
|
||||||
|
|
Loading…
Reference in New Issue