Author: dmeyer
Date: Mon Oct 29 13:49:04 2007
New Revision: 2890

Log:
create option to force the usage of the internal pynotifier copy

Modified:
   trunk/base/src/notifier/nf_wrapper.py

Modified: trunk/base/src/notifier/nf_wrapper.py
==============================================================================
--- trunk/base/src/notifier/nf_wrapper.py       (original)
+++ trunk/base/src/notifier/nf_wrapper.py       Mon Oct 29 13:49:04 2007
@@ -138,7 +138,7 @@
     return nf_socket_remove(id, nf_conditions[condition])
 
 
-def init( module = None, **options ):
+def init( module = None, use_pynotifier=True, **options ):
     global timer_add
     global socket_add
     global dispatcher_add
@@ -158,35 +158,35 @@
         options['recursive_depth'] = 5
         
     try:
+        if not use_pynotifier:
+            # pynotifier is not allowed
+            raise ImportError()
         import notifier
+        if notifier.loop:
+            raise RuntimeError('pynotifier loop already running')
     except ImportError:
         # use our own copy of pynotifier
         import pynotifier as notifier
 
-    if notifier.loop:
-        # pyNotifier should be used and already active
-        log = logging.getLogger('notifier')
-        log.info('pynotifier already running, I hope you know what you are 
doing')
-    else:
-        # find a good main loop
-        if not module and sys.modules.has_key('gtk'):
-            # The gtk module is loaded, this means that we will hook
-            # ourself into the gtk main loop
-            module = 'gtk'
-        elif not module:
-            # use generic
-            module = 'generic'
-
-        if getattr(notifier, module.upper()) is not None:
-            # use the selected module
-            notifier.init(getattr(notifier, module.upper()), **options)
-        elif module:
-            raise AttributeError('no notifier module %s' % module)
-
-        # delete basic notifier handler
-        log = logging.getLogger('notifier')
-        for l in log.handlers:
-            log.removeHandler(l)
+    # find a good main loop
+    if not module and sys.modules.has_key('gtk'):
+        # The gtk module is loaded, this means that we will hook
+        # ourself into the gtk main loop
+        module = 'gtk'
+    elif not module:
+        # use generic
+        module = 'generic'
+
+    if getattr(notifier, module.upper()) is not None:
+        # use the selected module
+        notifier.init(getattr(notifier, module.upper()), **options)
+    elif module:
+        raise AttributeError('no notifier module %s' % module)
+
+    # delete basic notifier handler
+    log = logging.getLogger('notifier')
+    for l in log.handlers:
+        log.removeHandler(l)
 
     timer_remove = notifier.timer_remove
     timer_add = notifier.timer_add

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to