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

Jan Luebbe jluebbe at debian.org
Mon Feb 2 18:52:04 UTC 2009


The following commit has been merged in the master branch:
commit 027fd5d65d98990837713c33278663e61e814e41
Author: Jan Luebbe <jluebbe at debian.org>
Date:   Tue Jan 27 09:59:40 2009 +0100

    oeventsd: support setting environment variables for the Command action (closes: #242)
    
    Thanks to Peter Strapp for the idea and a patch.

diff --git a/framework/subsystems/oeventsd/fso_actions.py b/framework/subsystems/oeventsd/fso_actions.py
index 5c51bb6..4fa119f 100644
--- a/framework/subsystems/oeventsd/fso_actions.py
+++ b/framework/subsystems/oeventsd/fso_actions.py
@@ -306,18 +306,26 @@ class CommandAction(Action):
 #=========================================================================#
     function_name = 'Command'
 
-    def __init__( self, cmd = 'true' ):
+    def __init__( self, cmd = 'true', env = {} ):
         self.cmd = cmd
+        self.env = env
 
     def trigger(self, **kargs):
         logger.info( "CommandAction %s", self.cmd )
 
+        env = {}
+        env.update( os.environ )
+        env.update( self.env )
+
         # FIXME if we are interested in tracking the process, then we
         # should use glib's spawn async and add a chile watch
-        subprocess.Popen( shlex.split( self.cmd ) )
+        try:
+            subprocess.Popen( shlex.split( self.cmd ), env = env )
+        except Exception, e:
+            logger.error( "Error while executing external command '%s': %s", self.cmd, e )
 
     def __repr__(self):
-        return "CommandAction(%s)" % self.cmd
+        return "CommandAction(%s, %s)" % ( self.cmd, self.env )
 
 #============================================================================#
 class SuspendAction(DBusAction):

-- 
FSO frameworkd Debian packaging



More information about the pkg-fso-commits mailing list