Skip to content

Commit

Permalink
Detecting gst-switch-srv path using PATH variable
Browse files Browse the repository at this point in the history
  • Loading branch information
hyades committed Dec 15, 2014
1 parent c74f41e commit 3772945
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions python-api/gstswitch/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import signal
import subprocess
from distutils import spawn

from errno import ENOENT
from .exception import PathError, ServerProcessError
Expand All @@ -22,8 +23,9 @@ class Server(object):

"""Control all server related operations
:param path: Path where all executables
gst-switch-srv, gst-launch-1.0, etc are located
:param path: Path where the executable gst-switch-srv
is located. Provide the full path.
By default looks in the current $PATH.
:param video_port: The video port number - default = 3000
:param audio_port: The audio port number - default = 4000
:param control_port: The control port number - default = 5000
Expand All @@ -34,7 +36,7 @@ class Server(object):

def __init__(
self,
path,
path=None,
video_port=3000,
audio_port=4000,
control_port=5000,
Expand Down Expand Up @@ -197,7 +199,20 @@ def run(self, gst_option=''):
def _run_process(self):
"""Non-public method: Runs the gst-switch-srv process
"""
cmd = self.path
cmd = ''
if self.path is None:
srv_location = spawn.find_executable('gst-switch-srv')
if srv_location:
cmd = '/'.join(srv_location.split('/')[:-1])
else:
raise PathError("Cannot find gst-switch-srv in $PATH.\
Please specify the path.")
else:
if self.path[-1] == '/':
cmd = self.path[:-1]
else:
cmd = self.path
cmd += '/'
cmd += """gst-switch-srv \
{0} \
--video-input-port={1} \
Expand Down

0 comments on commit 3772945

Please sign in to comment.