From 6207e607a857c522997c94e79da08056cb3846a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Sat, 24 Mar 2018 21:57:40 +0100 Subject: [PATCH] Fix NoneType Error element can be None if there was a error while calling Gst.ElementFactory.make() --- gajim/common/multimedia_helpers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gajim/common/multimedia_helpers.py b/gajim/common/multimedia_helpers.py index 19e21ed72..5b473c246 100644 --- a/gajim/common/multimedia_helpers.py +++ b/gajim/common/multimedia_helpers.py @@ -14,9 +14,12 @@ ## along with Gajim. If not, see . import gi +import logging gi.require_version('Gst', '1.0') from gi.repository import Gst +log = logging.getLogger('gajim.c.multimedia_helpers') + class DeviceManager(object): def __init__(self): @@ -33,6 +36,8 @@ class DeviceManager(object): def detect_element(self, name, text, pipe='%s'): if Gst.ElementFactory.find(name): element = Gst.ElementFactory.make(name, '%spresencetest' % name) + if element is None: + log.warning('could not create %spresencetest', name) if hasattr(element.props, 'device'): element.set_state(Gst.State.READY) devices = element.get_properties('device') @@ -49,7 +54,7 @@ class DeviceManager(object): else: self.devices[text] = pipe % name else: - print('element \'%s\' not found' % name) + log.info('element %s not found', name) class AudioInputManager(DeviceManager): @@ -108,4 +113,3 @@ class VideoOutputManager(DeviceManager): # ximagesink self.detect_element('ximagesink', _('X Window System (without Xv)')) self.detect_element('autovideosink', _('Autodetect')) -