Skip to content

Commit

Permalink
Fix pylint E1101 for coherence.transcoder
Browse files Browse the repository at this point in the history
  - E1101: Instance of 'BaseTranscoder' has no 'start' member (no-member)
  - E1101: Instance of 'BaseTranscoder' has no 'pipeline' member (no-member)
  - E1101: Instance of 'GStreamerTranscoder' has no 'pipeline_description' member (no-member)
  - E1101: Instance of 'ExternalProcessPipeline' has no 'pipeline_description' member (no-member)
  - E1101: Instance of 'ExternalProcessPipeline' has no 'contentType' member (no-member)
  • Loading branch information
opacam committed Sep 13, 2018
1 parent a2a0ae3 commit f3229d6
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions coherence/transcoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,13 @@ class BaseTranscoder(resource.Resource, log.LogAble):
logCategory = 'transcoder'
addSlash = True

def __init__(self, uri, destination=None):
def __init__(self, uri, destination=None, content_type=None):
if uri[:7] not in ['file://', 'http://']:
uri = 'file://' + urllib.parse.quote(uri) # FIXME
self.uri = uri
self.destination = destination
self.contentType = None
self.pipeline = None
resource.Resource.__init__(self)
log.LogAble.__init__(self)
self.info('uri %s %r', uri, type(uri))
Expand All @@ -332,7 +334,7 @@ def getChild(self, name, request):
def render_GET(self, request):
self.info('render GET %r', request)
request.setResponseCode(200)
if hasattr(self, 'contentType'):
if self.contentType is not None:
request.setHeader(b'Content-Type', self.contentType)
request.write(b'')

Expand Down Expand Up @@ -371,6 +373,11 @@ def on_message(self, bus, message):
def cleanup(self):
self.pipeline.set_state(Gst.State.NULL)

def start(self, request=None):
"""This method should be sub classed for each
class which inherits from BaseTranscoder"""
pass


class PCMTranscoder(BaseTranscoder, InternalTranscoder):
contentType = 'audio/L16;rate=44100;channels=2'
Expand Down Expand Up @@ -543,8 +550,13 @@ class GStreamerTranscoder(BaseTranscoder):
same for the attribute contentType
"""
pipeline_description = None

def start(self, request=None):
if self.pipeline_description is None:
raise NotImplementedError(
"Warning: operation cancelled. You must set a value for "
"GStreamerTranscoder.pipeline_description")
self.info("start %r", request)
self.pipeline = Gst.parse_launch(self.pipeline_description % self.uri)
enc = self.pipeline.get_by_name('mux')
Expand Down Expand Up @@ -643,6 +655,8 @@ def stopProducing(self):
class ExternalProcessPipeline(resource.Resource, log.LogAble):
logCategory = 'externalprocess'
addSlash = False
pipeline_description = None
contentType = None

def __init__(self, uri):
self.uri = uri
Expand All @@ -654,11 +668,12 @@ def getChildWithDefault(self, path, request):

def render(self, request):
print("ExternalProcessPipeline render")
try:
if self.contentType:
request.setHeader('Content-Type', self.contentType)
except AttributeError:
pass
if self.pipeline_description is None:
raise NotImplementedError(
"Warning: operation cancelled. You must set a value for "
"ExternalProcessPipeline.pipeline_description")
if self.contentType is not None:
request.setHeader(b'Content-Type', self.contentType)

ExternalProcessProducer(self.pipeline_description % self.uri, request)
return server.NOT_DONE_YET
Expand Down

0 comments on commit f3229d6

Please sign in to comment.