mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2025-12-31 08:50:41 +00:00
Update test_wave_parsing.py
2.7 test support
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import os.path
|
import os.path
|
||||||
|
import sys
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
from subprocess import PIPE
|
from subprocess import PIPE
|
||||||
@@ -13,15 +14,25 @@ FFPROBE='ffprobe'
|
|||||||
def ffprobe(path):
|
def ffprobe(path):
|
||||||
|
|
||||||
arguments = [ FFPROBE , "-of", "json" , "-show_format", "-show_streams", path ]
|
arguments = [ FFPROBE , "-of", "json" , "-show_format", "-show_streams", path ]
|
||||||
|
|
||||||
|
if int(sys.version[0]) < 3:
|
||||||
|
process = subprocess.Popen(arguments, stdout=PIPE)
|
||||||
|
process.wait()
|
||||||
|
if process.returncode == 0:
|
||||||
|
output = process.communicate()[0]
|
||||||
|
if output:
|
||||||
|
output_str = output.decode('utf-8')
|
||||||
|
return json.loads(output_str)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
process = subprocess.run(arguments, stdin=None, stdout=PIPE, stderr=PIPE)
|
||||||
|
|
||||||
process = subprocess.run(arguments, stdin=None, stdout=PIPE, stderr=PIPE)
|
if process.returncode == 0:
|
||||||
|
output_str = process.stdout.decode('utf-8')
|
||||||
if process.returncode == 0:
|
return json.loads(output_str)
|
||||||
output_str = process.stdout.decode('utf-8')
|
else:
|
||||||
return json.loads(output_str)
|
return None
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
class TestWaveInfo(TestCase):
|
class TestWaveInfo(TestCase):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user