]> git.parisson.com Git - timeside.git/commitdiff
- merge all api's into timeside.api
authorOlivier Guilyardi <olivier@samalyse.com>
Fri, 27 Nov 2009 18:27:23 +0000 (18:27 +0000)
committerOlivier Guilyardi <olivier@samalyse.com>
Fri, 27 Nov 2009 18:27:23 +0000 (18:27 +0000)
- add core.get_processor()
- put all exceptions into exceptions.py
- use SubProcessError instead of EncodeProcesError, DecodeProcessError and VampProcessError
- rename TimeSideError to Error (= timeside.Error)

32 files changed:
analyze/__init__.py
analyze/api.py [deleted file]
analyze/channels.py
analyze/dc.py
analyze/duration.py
analyze/encoding.py
analyze/format.py
analyze/max_level.py
analyze/mean_level.py
analyze/resolution.py
analyze/samplerate.py
analyze/vamp/core.py
api.py
core.py
decode/__init__.py
decode/api.py [deleted file]
decode/flac.py
decode/mp3.py
decode/ogg.py
decode/wav.py
encode/__init__.py
encode/api.py [deleted file]
encode/flac.py
encode/mp3.py
encode/ogg.py
encode/wav.py
exceptions.py [new file with mode: 0644]
graph/__init__.py
graph/api.py [deleted file]
graph/spectrogram_audiolab.py
graph/waveform_audiolab.py
tests/test.py

index 97c5cad5e22bde63e4f41912a90f52004936e6b4..307016e07e7f8fff62650b5d135296523a46c088 100644 (file)
@@ -1,5 +1,4 @@
 # -*- coding: utf-8 -*-
-from timeside.analyze.api import *
 from timeside.analyze.core import *
 from timeside.analyze.channels import *
 from timeside.analyze.format import *
diff --git a/analyze/api.py b/analyze/api.py
deleted file mode 100644 (file)
index 187dc29..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (c) 2007-2009 Guillaume Pellerin <yomguy@parisson.com>
-
-# This file is part of TimeSide.
-
-# TimeSide 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 2 of the License, or
-# (at your option) any later version.
-
-# TimeSide 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 TimeSide.  If not, see <http://www.gnu.org/licenses/>.
-
-# Author: Guillaume Pellerin <yomguy@parisson.com>
-
-from timeside.api import IProcessor
-
-class IAnalyzer(IProcessor):
-    """Media item analyzer driver interface"""
-
-    @staticmethod
-    def name():
-        """Return the analyzer name, such as "Mean Level", "Max level",
-        "Total length, etc..
-        """
-
-    @staticmethod
-    def unit():
-        """Return the unit of the data such as "dB", "seconds", etc...
-        """
-
-    def render(self, media, options=None):
-        """Return the result data of the process"""
-
index e09c6abddfb856eb71ed4c1ffadbd0eb26ad1414..6ad202dce19539b18f69ed7eb592db82dd773fb5 100644 (file)
@@ -20,7 +20,7 @@
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
 from timeside.analyze.core import *
-from timeside.analyze.api import IAnalyzer
+from timeside.api import IAnalyzer
 import numpy
 
 class ChannelAnalyser(AudioProcessor):
index 28d0a68708f00f7b49593f27c53234465cbf8052..43cfdb5dbee8a7da2dd3675c4fe32bc976f278a5 100644 (file)
@@ -20,7 +20,7 @@
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
 from timeside.analyze.core import *
-from timeside.analyze.api import IAnalyzer
+from timeside.api import IAnalyzer
 import numpy
 
 class MeanDCShiftAnalyser(AudioProcessor):
index 4ea94011cb1dd805fff305b7066060b8904a1bee..64546d02143677a3926ee38605f4b6637f25f797 100644 (file)
@@ -20,7 +20,7 @@
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
 from timeside.analyze.core import *
-from timeside.analyze.api import IAnalyzer
+from timeside.api import IAnalyzer
 import numpy
 import datetime
 
index 3ca3b927dacc67006234a0a767049d7f00e2c549..0448f4717a22501fa9bda34997b6580384ee4cb6 100644 (file)
@@ -20,7 +20,7 @@
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
 from timeside.analyze.core import *
-from timeside.analyze.api import IAnalyzer
+from timeside.api import IAnalyzer
 import numpy
 
 class EncodingAnalyser(AudioProcessor):
index 681afc381c429ed087b4dd478a994066c54b9e65..2c7fdf36f492e615dac16a9e905785ba6206088d 100644 (file)
@@ -20,7 +20,7 @@
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
 from timeside.analyze.core import *
-from timeside.analyze.api import IAnalyzer
+from timeside.api import IAnalyzer
 import numpy
 
 class FormatAnalyser(AudioProcessor):
index 95c2303ea299f5c537a643566ad2ca61390887f9..fa173fbd3076a2a1b06e6c1e804cd13bc91eee4f 100644 (file)
@@ -20,7 +20,7 @@
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
 from timeside.analyze.core import *
-from timeside.analyze.api import IAnalyzer
+from timeside.api import IAnalyzer
 import numpy
 
 class MaxLevelAnalyzer(AudioProcessor):
index ae9424d957371fdb90892084f47603db62697757..7f18f37ce9d092e436b3ce62d837a499a0febe7c 100644 (file)
@@ -20,7 +20,7 @@
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
 from timeside.analyze.core import *
-from timeside.analyze.api import IAnalyzer
+from timeside.api import IAnalyzer
 import numpy
 
 class MeanLevelAnalyser(AudioProcessor):
index b13820501e5b62688fa9ca7c5fa404e84065935a..6040fec4f619cb1da5582df6aeb61b9c9e6010d1 100644 (file)
@@ -20,7 +20,7 @@
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
 from timeside.analyze.core import *
-from timeside.analyze.api import IAnalyzer
+from timeside.api import IAnalyzer
 import numpy
 
 class ResolutionAnalyser(AudioProcessor):
index 8093537edf1f3de0fe4789fc7c14249eea5a436d..d235ebdb32197e3458514dc2ab7f253ba8b54c86 100644 (file)
@@ -20,7 +20,7 @@
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
 from timeside.analyze.core import *
-from timeside.analyze.api import IAnalyzer
+from timeside.api import IAnalyzer
 import numpy
 
 class SampleRateAnalyzer(AudioProcessor):
index 4c89c9717cbe5b63d16122119ad5dbf99e4ce516..fb0a3f440f25252e99481c5d02ba04facb573ee3 100644 (file)
@@ -21,7 +21,8 @@
 
 from timeside.core import *
 from tempfile import NamedTemporaryFile
-from timeside.analyze.api import IAnalyzer
+from timeside.api import IAnalyzer
+from timeside.exceptions import SubProcessError
 import os
 import random
 import subprocess
@@ -99,31 +100,16 @@ class VampCoreAnalyzer:
                     stdout = subprocess.PIPE,
                     close_fds = True)
         except:
-            raise VampProcessError('Command failure:', command, proc)
+            raise SubProcessError('Command failure:', command, proc)
             
         # Core processing
         while True:
             __chunk = proc.stdout.read(buffer_size)
             status = proc.poll()
             if status != None and status != 0:
-                raise VampProcessError('Command failure:', command, proc)
+                raise SubProcessError('Command failure:', command, proc)
             if len(__chunk) == 0:
                 break
             yield __chunk
         
 
-class VampProcessError(TimeSideError):
-
-    def __init__(self, message, command, subprocess):
-        self.message = message
-        self.command = str(command)
-        self.subprocess = subprocess
-
-    def __str__(self):
-        if self.subprocess.stderr != None:
-            error = self.subprocess.stderr.read()
-        else:
-            error = ''
-        return "%s ; command: %s; error: %s" % (self.message,
-                                                self.command,
-                                                error)
diff --git a/api.py b/api.py
index 48a7cf5c9613a07d9c01e0d978fe23b148fa0b48..344871e4276c4b3d0f9ff903458c7c1612112248 100644 (file)
--- a/api.py
+++ b/api.py
@@ -1,6 +1,8 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (c) 2009 Olivier Guilyardi <olivier@samalyse.com>
+# Copyright (C) 2007-2009 Parisson
+# Copyright (c) 2007 Olivier Guilyardi <olivier@samalyse.com>
+# Copyright (c) 2007-2009 Guillaume Pellerin <pellerin@parisson.com>
 #
 # This file is part of TimeSide.
 
@@ -20,6 +22,7 @@
 from timeside.component import Interface
 
 class IProcessor(Interface):
+    """Base processor interface"""
 
     @staticmethod
     def id():
@@ -31,3 +34,128 @@ class IProcessor(Interface):
         Typically this identifier is likely to be used during HTTP requests
         and be passed as a GET parameter. Thus it should be as short as possible."""
 
+class IEncoder(IProcessor):
+    """Encoder driver interface"""
+
+    def __init__(self, output, nchannels, samplerate):
+        """The constructor must always accept the output, nchannels and samplerate 
+        arguments.  It may accepts extra arguments such as bitrate, depth, etc.., 
+        but these must be optionnal, that is have a default value.
+        
+        The output must either be a filepath or a callback function/method for 
+        for the streaming mode. The callback must accept one argument which is 
+        block of binary data.
+        """
+
+    @staticmethod
+    def format():
+        """Return the encode/encoding format as a short string
+        Example: "MP3", "OGG", "AVI", ...
+        """
+
+    @staticmethod
+    def description():
+        """Return a string describing what this encode format provides, is good
+        for, etc... The description is meant to help the end user decide what
+        format is good for him/her
+        """
+
+    @staticmethod
+    def file_extension():
+        """Return the filename extension corresponding to this encode format"""
+
+    @staticmethod
+    def mime_type():
+        """Return the mime type corresponding to this encode format"""
+
+    def set_metadata(self, metadata):
+        """metadata is a tuple containing tuples for each descriptor return by
+        the dc.Ressource of the item, in the model order :
+        ((name1, value1),(name2, value2),(name1, value3), ...)"""
+
+    def update(self):
+        """Updates the metadata into the file passed as the output argument
+           to the constructor. This method can't be called in streaming
+           mode."""
+
+    def process(self, frames):
+        """Encode the frames passed as a numpy array, where columns are channels.
+        
+           In streaming mode the callback passed to the constructor is called whenever
+           a block of encoded data is ready."""
+
+    def finish(self):
+        """Flush the encoded data and close the output file/stream. Calling this method
+        may cause the streaming callback to be called if in streaming mode."""
+  
+
+class IDecoder(IProcessor):
+    """Decoder driver interface"""
+
+    @staticmethod
+    def format():
+        """Return the decode/encoding format as a short string 
+        Example: "MP3", "OGG", "AVI", ...
+        """
+   
+    @staticmethod
+    def description():
+        """Return a string describing what this decode format provides, is good 
+        for, etc... The description is meant to help the end user decide what 
+        format is good for him/her
+        """
+
+    @staticmethod
+    def file_extension():
+        """Return the filename extension corresponding to this decode format"""
+
+    @staticmethod
+    def mime_type():
+        """Return the mime type corresponding to this decode format"""
+
+    def process(self, source, options=None):
+        """Perform the decoding process and stream the result through a generator
+
+        source is the audio/video source file absolute path.
+
+        It is highly recommended that decode drivers implement some sort of
+        cache instead of re-encoding each time process() is called.
+
+        It should be possible to make subsequent calls to process() with
+        different items, using the same driver instance.
+        """
+
+class IGrapher(IProcessor):
+    """Media item visualizer driver interface"""
+
+    @staticmethod
+    def name():
+        """Return the graph name, such as "Waveform", "Spectral view",
+        etc..
+        """
+
+    def set_colors(self, background=None, scheme=None):
+        """Set the colors used for image generation. background is a RGB tuple,
+        and scheme a a predefined color theme name"""
+        pass
+
+    def render(self, media_item, width=None, height=None, options=None):
+        """Generator that streams the graph output as a PNG image"""
+
+class IAnalyzer(IProcessor):
+    """Media item analyzer driver interface"""
+
+    @staticmethod
+    def name():
+        """Return the analyzer name, such as "Mean Level", "Max level",
+        "Total length, etc..
+        """
+
+    @staticmethod
+    def unit():
+        """Return the unit of the data such as "dB", "seconds", etc...
+        """
+
+    def render(self, media, options=None):
+        """Return the result data of the process"""
+
diff --git a/core.py b/core.py
index c797db401d05646058a230343d0a2b582ff9bf0e..f2c87b76c2e1c1f396112edda95701b9b933f751 100644 (file)
--- a/core.py
+++ b/core.py
 
 from timeside.component import *
 from timeside.api import IProcessor
+from timeside.exceptions import Error, ApiError
 import re
 
-__all__ = ['Processor', 'Component', 'implements', 'processors', 'TimeSideError']
-
-class TimeSideError(Exception):
-    """Exception base class for errors in TimeSide."""
-    # FIXME: is this redundant with Django's error handling ?
+__all__ = ['Processor', 'MetaProcessor', 'implements', 'processors', 
+           'get_processor']
 
 _processors = {}
 
@@ -40,12 +38,11 @@ class MetaProcessor(MetaComponent):
         if new_class in implementations(IProcessor):
             id = str(new_class.id())
             if _processors.has_key(id):
-                raise TimeSideError("%s and %s have the same id: '%s'"
+                raise ApiError("%s and %s have the same id: '%s'"
                     % (new_class.__name__, _processors[id].__name__, id))
             if not MetaProcessor.valid_id.match(id):
-                raise TimeSideError("%s has a malformed id: '%s'"
+                raise ApiError("%s has a malformed id: '%s'"
                     % (new_class.__name__, id))
-                
 
             _processors[id] = new_class
 
@@ -60,3 +57,12 @@ def processors(interface=IProcessor, recurse=True):
     any of the descendants of this interface."""
     return implementations(interface, recurse)
     
+
+def get_processor(processor_id):
+    """Return a processor by its id"""
+    if not _processors.has_key(processor_id):
+        raise Error("No processor registered with id: '%s'" 
+              % processor_id)
+
+    return _processors[processor_id]
+
index 5af60e5ac348c3991ba553c0ed90ad6d97ee63a6..d04cfceb82dab4fb0aeb81073609ca64e0647305 100644 (file)
@@ -1,8 +1,7 @@
 # -*- coding: utf-8 -*-
 
-from timeside.decode.api import *
 from timeside.decode.core import *
 from timeside.decode.ogg import *
 from timeside.decode.flac import *
 from timeside.decode.wav import *
-from timeside.decode.mp3 import *
\ No newline at end of file
+from timeside.decode.mp3 import *
diff --git a/decode/api.py b/decode/api.py
deleted file mode 100644 (file)
index e3e6744..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2007-2009 Parisson
-# Copyright (c) 2007 Olivier Guilyardi <olivier@samalyse.com>
-# Copyright (c) 2007-2009 Guillaume Pellerin <pellerin@parisson.com>
-#
-# This file is part of TimeSide.
-
-# TimeSide 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 2 of the License, or
-# (at your option) any later version.
-
-# TimeSide 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 TimeSide.  If not, see <http://www.gnu.org/licenses/>.
-
-from timeside.api import IProcessor
-from timeside.core import TimeSideError
-
-class IDecoder(IProcessor):
-    """Decoder driver interface"""
-
-    @staticmethod
-    def format():
-        """Return the decode/encoding format as a short string 
-        Example: "MP3", "OGG", "AVI", ...
-        """
-   
-    @staticmethod
-    def description():
-        """Return a string describing what this decode format provides, is good 
-        for, etc... The description is meant to help the end user decide what 
-        format is good for him/her
-        """
-
-    @staticmethod
-    def file_extension():
-        """Return the filename extension corresponding to this decode format"""
-
-    @staticmethod
-    def mime_type():
-        """Return the mime type corresponding to this decode format"""
-
-    def process(self, source, options=None):
-        """Perform the decoding process and stream the result through a generator
-
-        source is the audio/video source file absolute path.
-
-        It is highly recommended that decode drivers implement some sort of
-        cache instead of re-encoding each time process() is called.
-
-        It should be possible to make subsequent calls to process() with
-        different items, using the same driver instance.
-        """
-
-
-class DecodeProcessError(TimeSideError):
-
-    def __init__(self, message, command, subprocess):
-        self.message = message
-        self.command = str(command)
-        self.subprocess = subprocess
-
-    def __str__(self):
-        if self.subprocess.stderr != None:
-            error = self.subprocess.stderr.read()
-        else:
-            error = ''
-        return "%s ; command: %s; error: %s" % (self.message,
-                                                self.command,
-                                                error)
index b9b02c2afa67ac7a4cf5860f1753a17095fde7db..5289713989656aa2c3ee17e08cd2398cc4aae646 100644 (file)
@@ -24,7 +24,7 @@ import string
 import subprocess
 
 from timeside.decode.core import *
-from timeside.decode.api import IDecoder
+from timeside.api import IDecoder
 from mutagen.flac import FLAC
 from tempfile import NamedTemporaryFile
 
index dc2c968ae4c3e831d89e860c2dc1d1603ed4103c..f4f19733dd0971efc73db4549407f1fe3be5eebd 100644 (file)
@@ -25,7 +25,7 @@ import string
 import subprocess
 
 from timeside.decode.core import *
-from timeside.decode.api import IDecoder
+from timeside.api import IDecoder
 
 
 class Mp3Decoder(DecoderCore):
index 3e22af0fd46fee391197a601388ca51c2d5c1c96..ffd6903945a3ff13b98923c2d20b674eaa45576d 100644 (file)
@@ -24,7 +24,7 @@ import string
 import subprocess
 
 from timeside.decode.core import *
-from timeside.decode.api import IDecoder
+from timeside.api import IDecoder
 from mutagen.oggvorbis import OggVorbis
 
 class OggDecoder(DecoderCore):
index be23402dd0bc75d7d2b6f1c49e3806ff92ce159b..08bca882a5a3a009dea37eeda1bdf265cd7ba56b 100644 (file)
@@ -24,7 +24,7 @@ import string
 import subprocess
 
 from timeside.decode.core import *
-from timeside.decode.api import IDecoder
+from timeside.api import IDecoder
 
 class WavDecoder(DecoderCore):
     """Defines methods to decode from WAV"""
index c4f041995c45de7893aaac2b02dc4502a2629924..a3dd62f7ab9ebaca63b1f208a536691147083d8e 100644 (file)
@@ -1,8 +1,7 @@
 # -*- coding: utf-8 -*-
 
-from timeside.encode.api import *
 from timeside.encode.core import *
 from timeside.encode.ogg import *
 from timeside.encode.wav import *
 from timeside.encode.mp3 import *
-from timeside.encode.flac import *
\ No newline at end of file
+from timeside.encode.flac import *
diff --git a/encode/api.py b/encode/api.py
deleted file mode 100644 (file)
index 9314c82..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2007-2009 Parisson
-# Copyright (c) 2007 Olivier Guilyardi <olivier@samalyse.com>
-# Copyright (c) 2007-2009 Guillaume Pellerin <pellerin@parisson.com>
-#
-# This file is part of TimeSide.
-
-# TimeSide 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 2 of the License, or
-# (at your option) any later version.
-
-# TimeSide 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 TimeSide.  If not, see <http://www.gnu.org/licenses/>.
-
-from timeside.core import TimeSideError
-from timeside.api import IProcessor
-
-class IEncoder(IProcessor):
-    """Encoder driver interface"""
-
-    def __init__(self, output, nchannels, samplerate):
-        """The constructor must always accept the output, nchannels and samplerate 
-        arguments.  It may accepts extra arguments such as bitrate, depth, etc.., 
-        but these must be optionnal, that is have a default value.
-        
-        The output must either be a filepath or a callback function/method for 
-        for the streaming mode. The callback must accept one argument which is 
-        block of binary data.
-        """
-
-    @staticmethod
-    def format():
-        """Return the encode/encoding format as a short string
-        Example: "MP3", "OGG", "AVI", ...
-        """
-
-    @staticmethod
-    def description():
-        """Return a string describing what this encode format provides, is good
-        for, etc... The description is meant to help the end user decide what
-        format is good for him/her
-        """
-
-    @staticmethod
-    def file_extension():
-        """Return the filename extension corresponding to this encode format"""
-
-    @staticmethod
-    def mime_type():
-        """Return the mime type corresponding to this encode format"""
-
-    def set_metadata(self, metadata):
-        """metadata is a tuple containing tuples for each descriptor return by
-        the dc.Ressource of the item, in the model order :
-        ((name1, value1),(name2, value2),(name1, value3), ...)"""
-
-    def update(self):
-        """Updates the metadata into the file passed as the output argument
-           to the constructor. This method can't be called in streaming
-           mode."""
-
-    def process(self, frames):
-        """Encode the frames passed as a numpy array, where columns are channels.
-        
-           In streaming mode the callback passed to the constructor is called whenever
-           a block of encoded data is ready."""
-
-    def finish(self):
-        """Flush the encoded data and close the output file/stream. Calling this method
-        may cause the streaming callback to be called if in streaming mode."""
-  
-class EncodeProcessError(TimeSideError):
-
-    def __init__(self, message, command, subprocess):
-        self.message = message
-        self.command = str(command)
-        self.subprocess = subprocess
-
-    def __str__(self):
-        if self.subprocess.stderr != None:
-            error = self.subprocess.stderr.read()
-        else:
-            error = ''
-        return "%s ; command: %s; error: %s" % (self.message,
-                                                self.command,
-                                                error)
-
index 3f43dbe9a84e0201dc586def8ca53fa4d8aa8eb9..c03eb93dbd66a7d3d2bb1a3e3d6b32276228a57b 100644 (file)
@@ -24,7 +24,7 @@ import string
 import subprocess
 
 from timeside.encode.core import *
-from timeside.encode.api import IEncoder
+from timeside.api import IEncoder
 from tempfile import NamedTemporaryFile
 
 class FlacEncoder(EncoderCore):
index 51fdf87d5396310746c2acab57dadd85e624a7df..a29d369da1bddd863fa4af3f6c462f1dafacc8a3 100644 (file)
@@ -25,7 +25,7 @@ import string
 import subprocess
 
 from timeside.encode.core import *
-from timeside.encode.api import IEncoder
+from timeside.api import IEncoder
 
 
 class Mp3Encoder(EncoderCore):
index ef1986301a2ac4673016eef207cc59c76fbf7fac..c0855f9e2c6a7997f7695bdd2bb1aa173f0ca505 100644 (file)
@@ -24,7 +24,7 @@ import string
 import subprocess
 
 from timeside.encode.core import *
-from timeside.encode.api import IEncoder
+from timeside.api import IEncoder
 
 class OggVorbisEncoder(EncoderCore):
     """Defines methods to encode to OGG Vorbis"""
index 54b8199ca0c8643361d29a1ed86126dbf2e4f3cc..19030503e4720cfcf3e40d3baf99aa2d05666376 100644 (file)
@@ -23,7 +23,7 @@ import os
 import string
 
 from timeside.encode.core import *
-from timeside.encode.api import IEncoder
+from timeside.api import IEncoder
 
 class WavEncoder(EncoderCore):
     """Defines methods to encode to WAV"""
diff --git a/exceptions.py b/exceptions.py
new file mode 100644 (file)
index 0000000..40b4dcd
--- /dev/null
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2009 Olivier Guilyardi <olivier@samalyse.com>
+#
+# This file is part of TimeSide.
+
+# TimeSide 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 2 of the License, or
+# (at your option) any later version.
+
+# TimeSide 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 TimeSide.  If not, see <http://www.gnu.org/licenses/>.
+
+class Error(Exception):
+    """Exception base class for errors in TimeSide."""
+
+class ApiError(Exception):
+    """Exception base class for errors in TimeSide."""
+
+class SubProcessError(Error):
+    """Exception for reporting errors from a subprocess"""
+
+    def __init__(self, message, command, subprocess):
+        self.message = message
+        self.command = str(command)
+        self.subprocess = subprocess
+
+    def __str__(self):
+        if self.subprocess.stderr != None:
+            error = self.subprocess.stderr.read()
+        else:
+            error = ''
+        return "%s ; command: %s; error: %s" % (self.message,
+                                                self.command,
+                                                error)
index 5d006e667382d3e2499d64e451aa8e5e89f423be..ae5da9daa610fede104373ce116e017f8a40e6d8 100644 (file)
@@ -1,5 +1,4 @@
 # -*- coding: utf-8 -*-
 
-from timeside.graph.api import *
 from timeside.graph.waveform_audiolab import *
 from timeside.graph.spectrogram_audiolab import *
diff --git a/graph/api.py b/graph/api.py
deleted file mode 100644 (file)
index fa1e941..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (C) 2007 Samalyse SARL#
-# Copyright (c) 2007-2009 Guillaume Pellerin <yomguy@parisson.com>
-
-# This file is part of TimeSide.
-
-# TimeSide 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 2 of the License, or
-# (at your option) any later version.
-
-# TimeSide 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 TimeSide.  If not, see <http://www.gnu.org/licenses/>.
-
-# Author: Guillaume Pellerin <yomguy@parisson.com>
-# Author: Olivier Guilyardi <olivier@samalyse.com>
-
-from timeside.api import IProcessor
-
-class IGrapher(IProcessor):
-    """Media item visualizer driver interface"""
-
-    @staticmethod
-    def name():
-        """Return the graph name, such as "Waveform", "Spectral view",
-        etc..
-        """
-
-    def set_colors(self, background=None, scheme=None):
-        """Set the colors used for image generation. background is a RGB tuple,
-        and scheme a a predefined color theme name"""
-        pass
-
-    def render(self, media_item, width=None, height=None, options=None):
-        """Generator that streams the graph output as a PNG image"""
index b731fa6d7ccac740cbd2f1345772053071fccfd4..709d8d387f0d74bb291ea1ef123ab13b9b9b41f3 100644 (file)
@@ -20,7 +20,7 @@
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
 from timeside.core import *
-from timeside.graph.api import IGrapher
+from timeside.api import IGrapher
 from tempfile import NamedTemporaryFile
 from timeside.graph.wav2png import *
 
index 62de0302b18d38853287989465cb54ecbe1faf81..b11888c8418eb5a8d81ac786806d151fe4531930 100644 (file)
@@ -20,7 +20,7 @@
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
 from timeside.core import *
-from timeside.graph.api import IGrapher
+from timeside.api import IGrapher
 from tempfile import NamedTemporaryFile
 from timeside.graph.wav2png import *
 
index 38cd4c92e2f68b6e6e4a732c7a0b3d3cf7cfdaf4..c54b44907b4bd3d501a4a393e2bbc443a6869907 100755 (executable)
@@ -7,8 +7,8 @@ import magic
 from timeside.core import *
 
 
-class TestAnalyzers(Component):
-    analyzers = processors(timeside.analyze.IAnalyzer)
+class TestAnalyzers:
+    analyzers = processors(timeside.api.IAnalyzer)
 
     def list(self):
         analyzers = []
@@ -34,8 +34,8 @@ class TestAnalyzers(Component):
             print id + ' = ' + str(value) + ' ' + analyzer.unit()
 
 
-class TestDecoders(Component):
-    decoders = processors(timeside.decode.IDecoder)
+class TestDecoders:
+    decoders = processors(timeside.api.IDecoder)
 
     def list(self):
         decoders_list = []
@@ -71,8 +71,8 @@ class TestDecoders(Component):
                     f.flush()
                 f.close()
 
-class TestEncoders(Component):
-    encoders = processors(timeside.encode.IEncoder)
+class TestEncoders:
+    encoders = processors(timeside.api.IEncoder)
 
     def list(self):
         encoders = []
@@ -108,8 +108,8 @@ class TestEncoders(Component):
             file.close()
 
 
-class TestGraphers(Component):
-    graphers = processors(timeside.graph.IGrapher)
+class TestGraphers:
+    graphers = processors(timeside.api.IGrapher)
 
     def list(self):
         graphers = []