Skip to content

Commit

Permalink
Fixed problems
Browse files Browse the repository at this point in the history
  • Loading branch information
hyades committed Jul 17, 2013
1 parent b5e4a40 commit 48e1742
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 16 deletions.
53 changes: 38 additions & 15 deletions python-api/gstswitch/server.py
Expand Up @@ -132,8 +132,34 @@ def get_record_file(self):
raise ValueError("Record file name should not have '/'")
return self.RECORD_FILE

def set_executable_path(self, path):
"""Sets the path where all exceutables
gst-switch-srv, gst-launch-1.0, wtc are located
:param path: Path where exceutables are present
:returns: nothing
"""
if type(path) != str:

This comment has been minimized.

Copy link
@mithro

mithro Jul 18, 2013

Collaborator

This isn't C you shouldn't be checking types like that.

How do you use path? Try doing that here...

raise TypeError("path should be of type str")
if len(str) == 0:

This comment has been minimized.

Copy link
@mithro

mithro Jul 18, 2013

Collaborator
if not str:
   raise TypeError("path should be of type str")
raise ValueError("path should be a string of length more than 0")
self.PATH = path

def get_executable_path(self, path):
"""Sets the path where all exceutables
gst-switch-srv, gst-launch-1.0, wtc are located
:param path: Path where exceutables are present
:returns: nothing
"""
if type(self.PATH) != str:
raise TypeError("path not set correctly: should be a str")
if len(self.PATH) == 0:
raise ValueError("path not set correctly: should have length more than 0")
return self.PATH

class ServerProcess(object):

class ServerProcess(BaseServer):
"""Class handling controlling the server process
:param: None
Expand All @@ -149,12 +175,18 @@ def run(self):
:param: None
:returns: nothing
"""

self.proc = None
self.pid = -1
print "Starting server"
self.proc = self._run_process()
try:
self.proc = self._run_process()
except:
raise RuntimeError("cannot creating gst-switch-srv process")
if self.proc is None:
pass
raise RuntimeError("cannot create gst-switch-srv process: No process created")
if self.proc.pid < 0:
raise RuntimeError("cannot create gst-switch-srv process: PID returned is negative")
else:
self.pid = self.proc.pid
# TODO: Sleep time may vary
Expand All @@ -163,13 +195,13 @@ def run(self):
def _run_process(self):
"""Private method for running gst-switch-srv process
"""
cmd = self.PATH
cmd = self.get_executable_path()
# cmd = ''
cmd += """gst-switch-srv \
--video-input-port=%s \
--audio-input-port=%s \
--control-port=%s \
--record=%s """ % (self.VIDEO_PORT, self.AUDIO_PORT, self.CONTROL_PORT, self.RECORD_FILE)
--record=%s """ % (self.get_video_port(), self.get_audio_port(), self.get_control_port(), self.get_video_port())
proc = self._start_process(cmd)
print "process:", proc
if proc is None:
Expand Down Expand Up @@ -215,17 +247,8 @@ def kill(self):
"""
os.kill(self.pid, signal.SIGKILL)

def set_executable_path(self, path):
"""Sets the path where all exceutables
gst-switch-srv, gst-launch-1.0, wtc are located
:param path: Path where exceutables are present
:returns: nothing
"""
self.PATH = path


class Server(BaseServer, ServerProcess):
class Server(ServerProcess):
"""Controls all Server operations
:param path: Path where all exceutables gst-switch-srv, gst-launch-1.0, etc are located
Expand Down
3 changes: 2 additions & 1 deletion python-api/gstswitch/test_BaseServer.py
Expand Up @@ -352,4 +352,5 @@ def test_normal(self):
name = "recordFile"
instance = BaseServer()
instance.RECORD_FILE = name
assert name == instance.get_record_file()
assert name == instance.get_record_file()

7 changes: 7 additions & 0 deletions python-api/gstswitch/test_ServerProcess.py
@@ -0,0 +1,7 @@
from server import ServerProcess
import pytest

class TestRun(object):

def test_():
pass

0 comments on commit 48e1742

Please sign in to comment.