[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, master, updated. milestone4-368-g700ab82

Michael 'Mickey' Lauer mickey at vanille-media.de
Mon Feb 2 18:52:03 UTC 2009


The following commit has been merged in the master branch:
commit 11bf304b3f06081b9336cb4eeec9c9620f62cfad
Author: Michael 'Mickey' Lauer <mickey at vanille-media.de>
Date:   Sat Jan 24 02:23:09 2009 +0100

    resource: add resource.checkedsignal decorator. In contrast to resource.queuedsignal, this
    will throw a signal away, if the corresponding resource is not enabled. Feel free to change
    signals with short validity periods from queuedsignal to checkedsignal.

diff --git a/framework/resource.py b/framework/resource.py
index 4a5281c..4faec78 100644
--- a/framework/resource.py
+++ b/framework/resource.py
@@ -13,7 +13,7 @@ Module: resource
 """
 
 MODULE_NAME = "frameworkd.resource"
-__version__ = "0.4.0"
+__version__ = "0.4.1"
 
 from framework.config import config
 from framework.patterns import decorator
@@ -40,7 +40,7 @@ def checkedmethod(f, *args, **kw):
     if self._resourceStatus == "enabled":
         return f(*args, **kw)
     else:
-        dbus_error( ResourceNotEnabled( "Resource is not enabled, current status is '%s'" % self._resourceStatus ) )
+        dbus_error( ResourceNotEnabled( "Resource %s is not enabled, current status is '%s'" % ( self.__class__.__name__, self._resourceStatus ) ) )
 
 #----------------------------------------------------------------------------#
 @decorator.decorator
@@ -54,14 +54,14 @@ def checkedsyncmethod(f, *args, **kw):
     if self._resourceStatus == "enabled":
         return f(*args, **kw)
     else:
-        dbus_error( ResourceNotEnabled( "Resource is not enabled, current status is '%s'" % self._resourceStatus ) )
+        dbus_error( ResourceNotEnabled( "Resource %s is not enabled, current status is '%s'" % ( self.__class__.__name__, self._resourceStatus ) ) )
 
 #----------------------------------------------------------------------------#
 @decorator.decorator
 def queuedsignal(f, *args, **kw):
     """
     This decorator wraps a dbus signal and sends it only if the resource is enabled.
-    Otherwise, it enqueues the signals.
+    Otherwise, it enqueues the signal.
     """
     #print "calling %s with args %s, %s" % (f.func_name, args, kw)
     self = args[0]
@@ -71,6 +71,20 @@ def queuedsignal(f, *args, **kw):
         self._delayedSignalQueue.put( ( f, args ) ) # push for later
 
 #----------------------------------------------------------------------------#
+ at decorator.decorator
+def checkedsignal(f, *args, **kw):
+    """
+    This decorator wraps a dbus signal and sends it only if the resource is enabled.
+    Otherwise, it drops the signal.
+    """
+    #print "calling %s with args %s, %s" % (f.func_name, args, kw)
+    self = args[0]
+    if self._resourceStatus == "enabled":
+        return f(*args, **kw)
+    else:
+        logger.info( "Dropping signal %s, since resource %s is not enabled. Current status is '%s'" % ( f.__name__, self.__class__.__name__, self._resourceStatus ) )
+
+#----------------------------------------------------------------------------#
 class ResourceNotEnabled( dbus.DBusException ):
 #----------------------------------------------------------------------------#
     _dbus_error_name = "org.freesmartphone.Resource.NotEnabled"
@@ -81,11 +95,6 @@ class ResourceError( dbus.DBusException ):
     _dbus_error_name = "org.freesmartphone.Resource.Error"
 
 #----------------------------------------------------------------------------#
-class ResourceSuspendVeto( dbus.DBusException ):
-#----------------------------------------------------------------------------#
-    _dbus_error_name = "org.freesmartphone.Resource.SuspendVeto"
-
-#----------------------------------------------------------------------------#
 class Resource( dbus.service.Object ):
 #----------------------------------------------------------------------------#
     """

-- 
FSO frameworkd Debian packaging



More information about the pkg-fso-commits mailing list