Skip to content

Commit

Permalink
ported check.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bananadine committed Jun 21, 2013
1 parent dbf3f98 commit 1cd8163
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions flumotion/worker/checks/check.py
Expand Up @@ -17,7 +17,9 @@

import os

import gst
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst
from twisted.internet import defer

from flumotion.common import documentation, errors, gstreamer, log, messages
Expand Down Expand Up @@ -45,25 +47,25 @@ def handleGStreamerDeviceError(failure, device, mid=None):
gerror.message, gerror.domain, gerror.code, debug))

if gerror.domain == "gst-resource-error-quark":
if gerror.code == int(gst.RESOURCE_ERROR_OPEN_READ):
if gerror.code == int(Gst.RESOURCE_ERROR_OPEN_READ):
m = messages.Error(T_(
N_("Could not open device '%s' for reading. "
"Check permissions on the device."), device), mid=mid)
documentation.messageAddFixBadPermissions(m)
if gerror.code == int(gst.RESOURCE_ERROR_OPEN_WRITE):
if gerror.code == int(Gst.RESOURCE_ERROR_OPEN_WRITE):
m = messages.Error(T_(
N_("Could not open device '%s' for writing. "
"Check permissions on the device."), device), mid=mid)
documentation.messageAddFixBadPermissions(m)
elif gerror.code == int(gst.RESOURCE_ERROR_OPEN_READ_WRITE):
elif gerror.code == int(Gst.RESOURCE_ERROR_OPEN_READ_WRITE):
m = messages.Error(T_(
N_("Could not open device '%s'. "
"Check permissions on the device."), device), mid=mid)
documentation.messageAddFixBadPermissions(m)
elif gerror.code == int(gst.RESOURCE_ERROR_BUSY):
elif gerror.code == int(Gst.RESOURCE_ERROR_BUSY):
m = messages.Error(T_(
N_("Device '%s' is already in use."), device), mid=mid)
elif gerror.code == int(gst.RESOURCE_ERROR_SETTINGS):
elif gerror.code == int(Gst.RESOURCE_ERROR_SETTINGS):
m = messages.Error(T_(
N_("Device '%s' did not accept the requested settings."),
device),
Expand Down Expand Up @@ -134,7 +136,7 @@ def errbackNotFoundResult(failure, result, mid, device):
source, gerror, debug = failure.value.args

if gerror.domain == "gst-resource-error-quark" and \
gerror.code == int(gst.RESOURCE_ERROR_NOT_FOUND):
gerror.code == int(Gst.RESOURCE_ERROR_NOT_FOUND):
m = messages.Warning(T_(
N_("No device found on %s."), device), mid=mid)
result.add(m)
Expand Down Expand Up @@ -164,9 +166,9 @@ def checkElements(elementNames):
ret = []
for name in elementNames:
try:
gst.element_factory_make(name)
Gst.ElementFactory.make(name)
ret.append(name)
except gst.PluginNotFoundError:
except Gst.PluginNotFoundError:
log.debug('check', 'no plugin found for element factory %s', name)
pass
log.debug('check', 'checkElements: returning elements names %r', ret)
Expand Down Expand Up @@ -253,7 +255,7 @@ def discovered(dcv, ismedia):
result.succeed((True, properties))
return d.callback(result)

from gst.extend import discoverer
from Gst.extend import discoverer
dcv = discoverer.Discoverer(filePath)
dcv.connect('discovered', discovered)
dcv.discover()
Expand Down Expand Up @@ -290,7 +292,7 @@ def checkPlugin(pluginName, packageName, minimumVersion=None,
documentation.messageAddGStreamerInstall(m)
result.add(m)
elif featureName:
r = gst.registry_get_default()
r = Gst.registry_get()
features = r.get_feature_list_by_plugin(pluginName)
byname = dict([(f.get_name(), f) for f in features])
if (featureName not in byname
Expand Down

0 comments on commit 1cd8163

Please sign in to comment.