[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, master, updated. milestone3-274-gd9a0e57
Michael 'Mickey' Lauer
mickey at vanille-media.de
Tue Nov 11 17:09:21 UTC 2008
The following commit has been merged in the master branch:
commit 903152ab0efdf400cf1006fb84d495b48f5d561b
Author: Michael 'Mickey' Lauer <mickey at vanille-media.de>
Date: Sun Nov 2 04:29:58 2008 +0100
* remove option parsing out of controller, into frameworkd
* add command line option for profiling with the python-hotshot profiler
diff --git a/ChangeLog b/ChangeLog
index 213ee15..c35f7e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-11-01 Michael Lauer <mickey at openmoko.org>
+
+ * Add command line argument for profiling with the python-hotshot profiler
+
2008-10-31 Michael Lauer <mickey at openmoko.org>
* [ogsmd] Added TI-Calypso specific modem option called 'ti_calypso_deep_sleep'.
diff --git a/framework/controller.py b/framework/controller.py
index 20d504c..a2688fb 100644
--- a/framework/controller.py
+++ b/framework/controller.py
@@ -20,7 +20,6 @@ import dbus, dbus.service
from dbus.mainloop.glib import DBusGMainLoop
from gobject import MainLoop, idle_add
-from optparse import OptionParser
import os, sys, types, time
import logging
@@ -33,31 +32,6 @@ except ImportError:
sys.exit( -1 )
#----------------------------------------------------------------------------#
-class TheOptionParser( OptionParser ):
-#----------------------------------------------------------------------------#
- def __init__( self ):
- OptionParser.__init__( self )
- self.set_defaults( overrides=[] )
- self.add_option( "-o", "--override",
- dest = "overrides",
- help = "override configuration",
- metavar = "SECTION.KEY=VALUE",
- action = "append"
- )
- self.add_option( "-s", "--subsystems",
- metavar = "system1,system2,system3,...",
- dest = "subsystems",
- default = "",
- help = "launch following subsystems (default=all)",
- action = "store",
- )
- self.add_option( "-d", "--daemonize",
- dest = "daemonize",
- help = "launch as daemon",
- action = "store_true",
- )
-
-#----------------------------------------------------------------------------#
class Controller( daemon.Daemon ):
#----------------------------------------------------------------------------#
"""
@@ -73,8 +47,9 @@ class Controller( daemon.Daemon ):
"""
return cls.objects[name]
- def __init__( self, path ):
+ def __init__( self, path, options ):
self.launchTime = time.time()
+ self.options = options
daemon.Daemon.__init__( self, "/tmp/frameworkd.pid" )
# dbus & glib mainloop
@@ -194,11 +169,8 @@ class Controller( daemon.Daemon ):
loglevel = loggingmap.get( config.getValue( section, "log_level", debug ) )
logger.debug( "setting logger for %s to %s" % ( section, loglevel ) )
logging.getLogger( section ).setLevel( loglevel )
- # FIXME configure handlers
def _handleOverrides( self ):
- self.options = TheOptionParser()
- self.options.parse_args()
self.config = config
for override in self.options.values.overrides:
diff --git a/framework/frameworkd b/framework/frameworkd
index b57320d..f9638ef 100755
--- a/framework/frameworkd
+++ b/framework/frameworkd
@@ -8,21 +8,70 @@ The Open Device Daemon - Python Implementation
GPLv2 or later
"""
-__version__ = "1.0.0"
+__version__ = "1.1.0"
import sys, os
+from optparse import OptionParser
-try:
- from framework import controller
-except ImportError:
- sys.path.append( os.path.dirname( os.path.abspath( os.path.curdir ) ) )
- from framework import controller
+#----------------------------------------------------------------------------#
+class TheOptionParser( OptionParser ):
+#----------------------------------------------------------------------------#
+ def __init__( self ):
+ OptionParser.__init__( self )
+ self.set_defaults( overrides=[] )
+ self.add_option( "-o", "--override",
+ dest = "overrides",
+ help = "override configuration",
+ metavar = "SECTION.KEY=VALUE",
+ action = "append"
+ )
+ self.add_option( "-s", "--subsystems",
+ metavar = "system1,system2,system3,...",
+ dest = "subsystems",
+ default = "",
+ help = "launch following subsystems (default=all)",
+ action = "store",
+ )
+ self.add_option( "-d", "--daemonize",
+ dest = "daemonize",
+ help = "launch as daemon",
+ action = "store_true",
+ )
+ self.add_option( "-p", "--profile",
+ metavar = "<filename>",
+ dest = "profile",
+ help = "launch in profile mode (needs python-hotshot)",
+ action = "store",
+ )
+#----------------------------------------------------------------------------#
if __name__ == "__main__":
- c = controller.Controller( "%s/subsystems" % os.path.dirname( controller.__file__ ) )
+#----------------------------------------------------------------------------#
+ options = TheOptionParser()
+ options.parse_args( sys.argv )
+
+ if options.values.profile:
+ try:
+ import hotshot
+ except ImportError:
+ print "python-hotshot not found. Can't profile"
+ sys.exit( -1 )
+ else:
+ print "WARNING: profiling mode. profiling to %s" % options.values.profile
+
+ try:
+ from framework import controller
+ except ImportError:
+ sys.path.append( os.path.dirname( os.path.abspath( os.path.curdir ) ) )
+ from framework import controller
+ c = controller.Controller( "%s/subsystems" % os.path.dirname( controller.__file__ ), options )
try:
- c.launch()
+ if options.values.profile:
+ profile = hotshot.Profile( options.values.profile )
+ profile.runcall( c.launch )
+ else:
+ c.launch()
except KeyboardInterrupt:
print >>sys.stderr, "ctrl-c: exiting."
c.shutdown()
--
FSO frameworkd Debian packaging
More information about the pkg-fso-commits
mailing list