Log a warning (rather than raising a Failure) on glob-loading a non-curve
[hooke.git] / hooke / plugin / playlist.py
index 85fd2d88ca4690a2dab0dbbcc9e9394334b31563..afd2ef9dc56558a7e213c6c171fb7ad8936b0ad8 100644 (file)
@@ -22,10 +22,12 @@ several associated :class:`hooke.command.Command`\s for handling
 """
 
 import glob
+import logging
 import os.path
 
 from ..command import Command, Argument, Failure
 from ..playlist import FilePlaylist
+from ..curve import NotRecognized
 from . import Builtin
 
 
@@ -247,6 +249,9 @@ Drivers for loading curves.
     def _run(self, hooke, inqueue, outqueue, params):
         p = FilePlaylist(drivers=params['drivers'], path=params['input'])
         p.load(hooke=hooke)
+        playlist_names = [playlist.name for playlist in hooke.playlists]
+        if p.name in playlist_names or p.name == None:
+            p.name = params['output playlist']  # HACK: override input name.  How to tell if it is callback-generated?
         self._set_playlist(hooke, params, p)
        outqueue.put(p)
 
@@ -297,10 +302,15 @@ Additional information for the input :class:`hooke.curve.Curve`.
             help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
+        p = self._playlist(hooke, params)
         for path in sorted(glob.glob(params['input'])):
-            self._playlist(hooke, params).append_curve_by_path(
-                path, params['info'], hooke=hooke)
-
+            try:
+                p.append_curve_by_path(path, params['info'], hooke=hooke)
+            except NotRecognized, e:
+                log = logging.getLogger('hooke')
+                log.warn(unicode(e))
+                continue
+            outqueue.put(p[-1])
 
 class RemoveCommand (PlaylistCommand):
     """Remove a curve from a playlist.