Skip to content

Commit

Permalink
Pylint helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
hyades committed Jul 25, 2013
1 parent 8094c21 commit 1761c80
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 20 deletions.
37 changes: 23 additions & 14 deletions python-api/gstswitch/helpers.py
@@ -1,8 +1,3 @@
import os
import sys
import signal
import subprocess
from gi.repository import Gio
from testsource import VideoSrc, Preview

__all__ = ["TestSources", "PreviewSinks"]
Expand All @@ -17,11 +12,22 @@ def __init__(self, video_port):
self.running_tests = []
self.video_port = video_port

def new_test_video(self, width=300, height=200, pattern=None, timeoverlay=False, clockoverlay=False):
def new_test_video(self,
width=300,
height=200,
pattern=None,
timeoverlay=False,
clockoverlay=False):
"""Start a new test source
"""
print 'Adding new test video source'
testsrc = VideoSrc(self.video_port, width, height, pattern, timeoverlay, clockoverlay)
testsrc = VideoSrc(
self.video_port,
width,
height,
pattern,
timeoverlay,
clockoverlay)
if testsrc is None:
pass
self.running_tests.append(testsrc)
Expand All @@ -30,8 +36,8 @@ def get_test_video(self):
"""Returns a list of processes acting as test inputs
"""
i = 0
for x in self.running_tests:
print i, "pattern:", x.pattern
for test in self.running_tests:
print i, "pattern:", test.pattern
i += 1
return self.running_tests

Expand All @@ -47,24 +53,27 @@ def terminate(self):
"""
"""
print 'TESTS:', self.running_tests
for x in range(len(self.running_tests)):
for test in range(len(self.running_tests)):
self.terminate_index(0)


class PreviewSinks(object):
"""docstring for PreviewSinks
"""
def __init__(self):
# TODO set preview port from dbus call

def __init__(self, preview_port=3001):
super(PreviewSinks, self).__init__()
self.PREVIEW_PORT = 3001
# TODO set preview port from dbus call
self.preview_port = preview_port

def run(self):
self.preview = Preview(self.PREVIEW_PORT)
"""Run the Preview Sink"""
self.preview = Preview(self.preview_port)
self.preview.run()
print 'start preview'

def terminate(self):
"""End/Terminate the Preview Sink"""
try:
self.preview.end()
print 'end preview'
Expand Down
33 changes: 27 additions & 6 deletions python-api/gstswitch/testsource.py
Expand Up @@ -2,8 +2,6 @@
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst

import os
import sys
import random

# from pipeline import *
Expand Down Expand Up @@ -45,7 +43,14 @@ class VideoPipeline(BasePipeline):
"""A Video Pipeline which can be used by a video test Source
"""

def __init__(self, port, width=300, height=200, pattern=None, timeoverlay=False, clockoverlay=False):
def __init__(
self,
port,
width=300,
height=200,
pattern=None,
timeoverlay=False,
clockoverlay=False):
super(VideoPipeline, self).__init__()

self.host = '127.0.0.1'
Expand Down Expand Up @@ -89,7 +94,10 @@ def make_videotestsrc(self, pattern):

def make_capsfilter(self, width, height):
element = self.make("capsfilter", "vfilter")
capsstring = "video/x-raw, format=(string)I420, width=%s, height=%s" % (str(width), str(height))
width = str(width)
height = str(height)
capsstring = "video/x-raw, format=(string)I420, "
"width=%s, height=%s".format(width, height)
caps = Gst.Caps.from_string(capsstring)
element.set_property('caps', caps)
return element
Expand Down Expand Up @@ -149,7 +157,14 @@ class VideoSrc(object):
"""A Test Video Source
"""

def __init__(self, port, width=300, height=200, pattern=None, timeoverlay=False, clockoverlay=False):
def __init__(
self,
port,
width=300,
height=200,
pattern=None,
timeoverlay=False,
clockoverlay=False):
super(VideoSrc, self).__init__()
self.port = port
self.width = width
Expand All @@ -158,7 +173,13 @@ def __init__(self, port, width=300, height=200, pattern=None, timeoverlay=False,
self.timeoverlay = timeoverlay
self.clockoverlay = clockoverlay

self.pipeline = VideoPipeline(self.port, self.width, self.height, self.pattern, self.timeoverlay, self.clockoverlay)
self.pipeline = VideoPipeline(
self.port,
self.width,
self.height,
self.pattern,
self.timeoverlay,
self.clockoverlay)
self.run()

def run(self):
Expand Down

0 comments on commit 1761c80

Please sign in to comment.