explicit initialization of the protocols so logging etc is all setup twisty
authorMark Hammond <mhammond@skippinet.com.au>
Sat, 14 Mar 2009 12:32:11 +1100
branchtwisty
changeset 91 9de17afe664b35030227ff79490c85c78cfff15f
parent 90 f974296bbdc5ba376ad328d05476457799678dd9
child 92 76fea0939f35c49b6d671e8fe2def7d0e0b6d269
push id1
push userroot
push dateWed, 08 Apr 2009 01:46:05 +0000
explicit initialization of the protocols so logging etc is all setup
server/python/junius/proto/__init__.py
server/python/junius/sync.py
--- a/server/python/junius/proto/__init__.py
+++ b/server/python/junius/proto/__init__.py
@@ -1,29 +1,25 @@
 # this needs to become a 'plugin' mechanism...
 
 _protocol_infos = [
     ('imap', 'junius.proto.imap', 'IMAPAccount'),
     ('skype', 'junius.proto.skype', 'SkypeAccount'),
     ('twitter', 'junius.proto.twitter', 'TwitterAccount'),
 ]
 
-# it must be time I looked up dict-comps ;)
 protocols = {}
-def _load():
+def init_protocols():
     import sys, logging
     logger = logging.getLogger('raindrop.proto')
     for name, mod, factname in _protocol_infos:
         try:
             __import__(mod)
             mod = sys.modules[mod]
             fact = getattr(mod, factname)
         except ImportError, why:
-            logger.info("Failed to import '%s' factory: %s", name, why)
+            logger.error("Failed to import '%s' factory: %s", name, why)
         except:
             logger.exception("Error creating '%s' factory", name)
         else:
             protocols[name] = fact
 
-_load()
-del _load
-
-__all__ = protocols
+__all__ = [protocols, init_protocols]
--- a/server/python/junius/sync.py
+++ b/server/python/junius/sync.py
@@ -8,16 +8,17 @@ from junius.model import get_db
 
 logger = logging.getLogger(__name__)
 
 _conductor = None
 
 def get_conductor(options=None):
   global _conductor
   if _conductor is None:
+    proto.init_protocols()
     _conductor = SyncConductor(options)
   else:
     assert options is None, 'can only set this at startup'
   return _conductor
   
   
 class SyncConductor(object):
   def __init__(self, options):