use python-deps to handle missing dependencies.

Apply it to gst python module.
This commit is contained in:
Thomas Vander Stichele
2013-01-27 22:24:22 +01:00
parent 434a7ca131
commit 6ac8408f0d
5 changed files with 51 additions and 6 deletions

View File

@@ -9,6 +9,7 @@ morituri_PYTHON = \
cache.py \
common.py \
config.py \
deps.py \
directory.py \
drive.py \
encode.py \

34
morituri/common/deps.py Normal file
View File

@@ -0,0 +1,34 @@
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
import os
import urllib
from morituri.extern.deps import deps
class DepsHandler(deps.DepsHandler):
def __init__(self, name='morituri'):
deps.DepsHandler.__init__(self, name)
self.add(GStPython())
def report(self, summary):
reporter = os.environ.get('EMAIL_ADDRESS', None)
get = "summary=%s" % urllib.quote(summary)
if reporter:
get += "&reporter=%s" % urllib.quote(reporter)
return 'http://thomas.apestaart.org/morituri/trac/newticket?' + get
class GStPython(deps.Dependency):
module = 'gst'
name = "GStreamer Python bindings"
homepage = "http://gstreamer.freedesktop.org"
def Fedora_install(self, distro):
return self.Fedora_yum('gstreamer-python')
#def Ubuntu_install(self, distro):
# pass

View File

@@ -18,6 +18,14 @@ command_PYTHON = \
command/__init__.py \
command/command.py
depsdir = $(PYTHONLIBDIR)/morituri/extern/deps
deps_PYTHON = \
deps/__init__.py \
deps/deps.py \
deps/distro.py
taskdir = $(PYTHONLIBDIR)/morituri/extern/task
task_PYTHON = \

View File

@@ -27,7 +27,6 @@ from morituri.extern.task import task
from morituri.common import logcommand, drive
from morituri.program import cdparanoia
class Analyze(logcommand.LogCommand):
summary = "analyze caching behaviour of drive"

View File

@@ -28,6 +28,9 @@ def main(argv):
log.debug('mapping distributions %r', distributions)
map(pkg_resources.working_set.add, distributions)
from morituri.common import deps
h = deps.DepsHandler()
c = Rip()
try:
ret = c.parse(argv)
@@ -35,12 +38,12 @@ def main(argv):
sys.stderr.write('rip: error: %s\n' % e.args)
return 255
except ImportError, e:
# FIXME: decide how to handle
raise
# deps.handleImportError(e)
# ret = -1
h.handleImportError(e)
except task.TaskException, e:
if isinstance(e.exception, common.MissingDependencyException):
if isinstance(e.exception, ImportError):
h.handleImportError(e.exception)
return 255
elif isinstance(e.exception, common.MissingDependencyException):
sys.stderr.write('rip: error: missing dependency "%s"\n' %
e.exception.dependency)
return 255