Commit 2e86c738 authored by Vincent A's avatar Vincent A

applications: replace spawnlp with subprocess.call and use shlex

- subprocess.call is much more common and easier to use
- use shlex to split to take care of quoted spaces
parent d55ab6d3
Pipeline #3125 passed with stages
in 15 minutes and 2 seconds
......@@ -231,7 +231,7 @@ class Downloadboob(object):
else:
return 1
os.spawnlp(os.P_WAIT, args[0], *args)
subprocess.call(args)
self.set_linkname(video)
def read_url(self, url):
......
......@@ -22,6 +22,7 @@ from __future__ import print_function
import os
import re
from shutil import which
import subprocess
import requests
......@@ -234,7 +235,7 @@ class Radioob(ReplApplication):
else:
return 1
os.spawnlp(os.P_WAIT, args[0], *args)
subprocess.call(args)
def complete_play(self, text, line, *ignored):
args = line.split(' ')
......
......@@ -22,6 +22,7 @@ from __future__ import print_function
from io import BytesIO
import os
from shutil import which
import subprocess
import requests
......@@ -128,7 +129,7 @@ class Videoob(ReplApplication):
return 1
self.logger.debug(' '.join(args))
os.spawnlp(os.P_WAIT, args[0], *args)
subprocess.call(args)
def read_url(self, url):
r = requests.get(url, stream=True)
......
......@@ -21,8 +21,9 @@
from __future__ import print_function
from contextlib import closing
import os
from subprocess import PIPE, Popen
import subprocess
import shlex
from shutil import which
import requests
......@@ -102,13 +103,11 @@ class MediaPlayer(object):
self._play_proxy(media, player_name, args)
return None
args = player_name.split(' ')
player_name = args[0]
args = shlex.split(player_name)
args.append(media.url)
print('Invoking "%s".' % (' '.join(args)))
os.spawnlp(os.P_WAIT, player_name, *args)
subprocess.call(args)
def _play_proxy(self, media, player_name, args):
"""
......@@ -175,11 +174,11 @@ class MediaPlayer(object):
assert args is not None
player_name = player_name.split(' ')
args = args.split(' ')
player_name = shlex.split(player_name)
args = shlex.split(args)
print(':: Streaming from %s' % media_url)
print(':: to %s %s' % (player_name, args))
print(':: %s' % rtmp)
p1 = Popen(rtmp.split(), stdout=PIPE)
p1 = Popen(shlex.split(rtmp), stdout=PIPE)
Popen(player_name + args, stdin=p1.stdout, stderr=PIPE)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment