Adjust hooke.playlist to allow spaces in .info keys.
[hooke.git] / hooke / hooke.py
index 859d634a2053ca5b9562887a07cb18763bf1b0b1..d1c3b9c7a9fd4d4a93e3294ae3bda41f705b2bfd 100644 (file)
@@ -54,10 +54,13 @@ if False: # Queue pickle error debugging code
         feed(buffer, notempty, s, writelock, close)
     multiprocessing.queues.Queue._feed = staticmethod(new_feed)
 
+import logging
+import logging.config
 import multiprocessing
 import optparse
 import os.path
 import unittest
+import StringIO
 import sys
 
 from . import engine as engine
@@ -81,13 +84,21 @@ class Hooke (object):
                 default_settings=default_settings)
             config.read()
         self.config = config
+        self.load_log()
         self.load_plugins()
         self.load_drivers()
         self.load_ui()
         self.command = engine.CommandEngine()
-
         self.playlists = playlist.NoteIndexList()
 
+    def load_log(self):
+        config_file = StringIO.StringIO()
+        self.config.write(config_file)
+        logging.config.fileConfig(StringIO.StringIO(config_file.getvalue()))
+        # Don't attach the logger because it contains an unpicklable
+        # thread.lock.  Instead, grab it directly every time you need it.
+        #self.log = logging.getLogger('hooke')
+
     def load_plugins(self):
         self.plugins = plugin_mod.load_graph(
             plugin_mod.PLUGIN_GRAPH, self.config, include_section='plugins')
@@ -163,9 +174,9 @@ def main():
         help='Add a command line Hooke command to run.')
     options,arguments = p.parse_args()
     if len(arguments) > 0:
-        print >> sys.stderr, 'Too many arguments to %s: %d > 0' \
-            % (sys.argv[0], len(arguments))
-        print >> sys.stderr, p.help()
+        print >> sys.stderr, 'More than 0 arguments to %s: %s' \
+            % (sys.argv[0], arguments)
+        p.print_help(sys.stderr)
         sys.exit(1)
 
     hooke = Hooke(debug=__debug__)