* introduce logcommand.Lager, Whipper(); use argparse for whipper image commands, stub logging * update Lager docstring to mention config.Config() * make incorrect subcommand and --version work on toplevel command * migrate accurip show, expand Lager, do not attempt to return from Lager.__init__. * migrate offset find, add Lager.error * correct offset find drive symlink handling * migrate drive * change Lager.__init__(prog) to arg from kwarg * but actually * remove Whipper.usage * add and use Lager.device_option() context manager * help I married an axe murderer * use unified options namespace for entire command tree * migrate whipper cd without comprehensive config loading * switch to logging module - use logging instead of flog for non-extern modules - use WHIPPER_DEBUG and WHIPPER_LOGFILE env variables * convert self.log calls to logger.debug * convert self.error calls to logger.error * remove log.Loggable, use logger not logging * Logging conversion continues - Convert log.* calls to logger.* - Remove morituri.common.log imports * remove morituri.common.log from tests * remove extern/flog, bare minimum Debug conversion * update README for logging changes * update soxi to use logging * refactor Lager for more declarative subcommands * Refactor Lager.device_option: - inline into __init__ - throw IOError instead of Exception for missing drives - remove CommandError checking in rip/main * rename rip to whipper in rip.main * convert rip.debug commands * Rename logcommand.Lager to command.BaseCommand - remove command.CommandError occurrences - remove python-command external module * remove submodules from README, update rclog formatter * update minor ambiguity in readme for command invocation * update version number to match setup.py * remove gitmodules * update version number in tests as well (boo) * convert logger.error to logger.critical * Change morituri.rip to morituri.command - mv common.command to command.basecommand - move TEMPLATES used only by rip.cd out of rip.common - update entry point for command to command.main * update basecommand documentation * go pyflaking: import fixing * replace self.stdout with sys.stdout * remove BaseCommand.config, alphabetise imports * convert self.stdXXX leftovers * convert last getRootCommand to config.Config * convert last getExceptionMessage's to str * change musicbrainz useragent to whipper
87 lines
2.6 KiB
Python
87 lines
2.6 KiB
Python
# -*- Mode: Python; test-case-name: morituri.test.test_common_gstreamer -*-
|
|
# vi:si:et:sw=4:sts=4:ts=4
|
|
|
|
# Morituri - for those about to RIP
|
|
|
|
# Copyright (C) 2009 Thomas Vander Stichele
|
|
|
|
# This file is part of morituri.
|
|
#
|
|
# morituri is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# morituri is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with morituri. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
import re
|
|
import commands
|
|
|
|
import logging
|
|
logger = logging.getLogger(__name__)
|
|
|
|
# workaround for issue #64
|
|
|
|
|
|
def removeAudioParsers():
|
|
logger.debug('Removing buggy audioparsers plugin if needed')
|
|
|
|
import gst
|
|
registry = gst.registry_get_default()
|
|
|
|
plugin = registry.find_plugin("audioparsersbad")
|
|
if plugin:
|
|
# always remove from bad
|
|
logger.debug('removing audioparsersbad plugin from registry')
|
|
registry.remove_plugin(plugin)
|
|
|
|
plugin = registry.find_plugin("audioparsers")
|
|
if plugin:
|
|
logger.debug('removing audioparsers plugin from %s %s',
|
|
plugin.get_source(), plugin.get_version())
|
|
|
|
# the query bug was fixed after 0.10.30 and before 0.10.31
|
|
# the seek bug is still there though
|
|
# if plugin.get_source() == 'gst-plugins-good' \
|
|
# and plugin.get_version() > '0.10.30.1':
|
|
# return
|
|
|
|
registry.remove_plugin(plugin)
|
|
|
|
def gstreamerVersion():
|
|
import gst
|
|
return _versionify(gst.version())
|
|
|
|
def gstPythonVersion():
|
|
import gst
|
|
return _versionify(gst.pygst_version)
|
|
|
|
_VERSION_RE = re.compile(
|
|
"Version:\s*(?P<version>[\d.]+)")
|
|
|
|
def elementFactoryVersion(name):
|
|
# surprisingly, there is no python way to get from an element factory
|
|
# to its plugin and its version directly; you can only compare
|
|
# with required versions
|
|
# Let's use gst-inspect-0.10 and wave hands and assume it points to the
|
|
# same version that python uses
|
|
output = commands.getoutput('gst-inspect-0.10 %s | grep Version' % name)
|
|
m = _VERSION_RE.search(output)
|
|
if not m:
|
|
return None
|
|
return m.group('version')
|
|
|
|
|
|
def _versionify(tup):
|
|
l = list(tup)
|
|
if len(l) == 4 and l[3] == 0:
|
|
l = l[:3]
|
|
v = [str(n) for n in l]
|
|
return ".".join(v)
|