Skip to content

Commit

Permalink
added exception for subprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
hyades committed Jul 18, 2013
1 parent 9f8434c commit 8ef1346
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions python-api/gstswitch/server.py
Expand Up @@ -31,6 +31,8 @@ def run(self, gst_option=''):
"""Launches the server process
:param: None
:gst-option: Any gstreamer option. Refer to http://www.linuxmanpages.com/man1/gst-launch-0.8.1.php#lbAF.
Should be added with spaces between them
:returns: nothing
"""
self.proc = None
Expand Down Expand Up @@ -58,10 +60,7 @@ def _run_process(self):
self.control_port,
self.record_file)
proc = self._start_process(cmd)
if proc is None:
raise RuntimeError("unable to create process: %s" % (proc))
else:
return proc
return proc

def _start_process(self, cmd):
"""Private method for starting a process
Expand All @@ -70,8 +69,13 @@ def _start_process(self, cmd):
:returns: process created
"""
print 'Creating process %s' % (cmd)
tempf = open(os.devnull, 'w')
process = subprocess.Popen(cmd.split(), stdout=tempf, stderr=tempf, bufsize=-1, shell=False)
try:
tempf = open(os.devnull, 'w')
process = subprocess.Popen(cmd.split(), stdout=tempf, stderr=tempf, bufsize=-1, shell=False)
except IOError:
print "Cannot open os.devnull"
except OSError:
print "gst-switch-srv not found in path"
return process

def terminate(self):
Expand Down

0 comments on commit 8ef1346

Please sign in to comment.