[cig-commits] r5988 - in cs/pythia/trunk: pyre/applications pyre/hooks pythia.egg-info

leif at geodynamics.org leif at geodynamics.org
Thu Feb 8 17:45:52 PST 2007


Author: leif
Date: 2007-02-08 17:45:52 -0800 (Thu, 08 Feb 2007)
New Revision: 5988

Modified:
   cs/pythia/trunk/pyre/applications/Application.py
   cs/pythia/trunk/pyre/applications/Shell.py
   cs/pythia/trunk/pyre/applications/__init__.py
   cs/pythia/trunk/pyre/hooks/ultraTB.odb
   cs/pythia/trunk/pythia.egg-info/
Log:
Made 'journal' configurable in the traditional way.  For example:

    myscript --journal.debug.myscript --journal.device=file

will turn-on 'myscript' debug log messages and send all journal
messages to a file.  Note: this is all done via smoke and mirrors.
Under CIG-Pyre, 'journal' is not an ordinary facility, because it must
be initialized early.  See the log comment for r5356.

Made Application.run() fire-up the new start-up procedure, so that the
official Pyre test cases and examples will behave identically to newer
stuff that goes through pyre.applications.start().

Finally, changed the default for "excepthook.call-pdb" to 'False'.
The call_pdb feature seems to be broken in the latest version of
IPython (0.7.3).  Besides, landing in pdb after an exception is
arguably unexpected behavior.


Modified: cs/pythia/trunk/pyre/applications/Application.py
===================================================================
--- cs/pythia/trunk/pyre/applications/Application.py	2007-02-08 23:55:18 UTC (rev 5987)
+++ cs/pythia/trunk/pyre/applications/Application.py	2007-02-09 01:45:52 UTC (rev 5988)
@@ -37,65 +37,9 @@
 
 
     def run(self, *args, **kwds):
-
-        # build storage for the user input
-        registry = self.createRegistry()
-        self.registry = registry
-
-        # command line
-        argv = self.getArgv(*args, **kwds)
-        commandLine = self.processCommandline(registry, argv)
-        action = commandLine.action
-        self.argv = commandLine.processed
-        self.unprocessedArguments = commandLine.unprocessed
-
-        # curator
-        curator = self.createCurator()
-        self.initializeCurator(curator, registry)
-
-        # config context
-        context = self.newConfigContext()
-
-        # look for my settings
-        self.initializeConfiguration()
-
-        # read parameter files given on the command line
-        self.readParameterFiles(registry, context)
-
-        # give descendants an opportunity to collect input from other (unregistered) sources
-        self.collectUserInput(registry, context)
-
-        # update user options from the command line
-        self.updateConfiguration(registry)
-
-        # transfer user input to my inventory
-        self.applyConfiguration(context)
-
-        # verify that the user input did not contain any typos
-        if not self.verifyConfiguration(context, self.inventory.typos):
-            import sys
-            sys.exit("%s: configuration error(s)" % self.name)
-
-        # initialize the trait cascade
-        self.init()
-
-        # print a startup page
-        self.generateBanner()
-
-        # the main application behavior
-        action = action and getattr(self, action)
-        if action:
-            action()
-        elif self._showHelpOnly:
-            pass
-        else:
-            message = kwds.get('message', 'execute')
-            method = getattr(self, message)
-            method(*args, **kwds)
-
-        # shutdown
-        self.fini()
-
+        from Shell import Shell
+        shell = Shell(self)
+        shell.run(*args, **kwds)
         return
 
 
@@ -134,7 +78,7 @@
                 else:
                     paramRegistry = shelf['inventory'].getFacility(self.name)
                     if paramRegistry:
-                        self.updateConfiguration(paramRegistry)
+                        registry.update(paramRegistry)
             else:
                 self.argv.append(arg)
         return

Modified: cs/pythia/trunk/pyre/applications/Shell.py
===================================================================
--- cs/pythia/trunk/pyre/applications/Shell.py	2007-02-08 23:55:18 UTC (rev 5987)
+++ cs/pythia/trunk/pyre/applications/Shell.py	2007-02-09 01:45:52 UTC (rev 5988)
@@ -14,39 +14,123 @@
 from pyre.components import Component
 
 
-class Shell(Component):
+try:
+    import IPython.ultraTB
+    defaultExceptHook = "ultraTB"
+except ImportError:
+    defaultExceptHook = "current"
 
 
-    name = "shell"
+class Shell(Component):
 
 
     import pyre.hooks
-    excepthook = pyre.hooks.facility("excepthook", family="excepthook", default="ultraTB")
+    excepthook = pyre.hooks.facility("excepthook", family="excepthook",
+                                     default=defaultExceptHook)
 
     import journal
     journal = journal.facility()
     journal.meta['tip'] = 'the logging facility'
 
 
-    def runApplication(self, ApplicationClass, **kwds):
-        import pyre.inventory
-        registry = self.createRegistry()
-        self.registry = registry
-        curator = pyre.inventory.curator(self.name)
-        curator.config(registry)
+    def __init__(self, app):
+        Component.__init__(self, app.name)
+
+        self.app = app
+        self.registry = None
+
+
+    def xupdateConfiguration(self, registry):
+        """divide settings between myself and the application"""
+        
+        myRegistry, yourRegistry = self.filterConfiguration(registry)
+        self.app.updateConfiguration(yourRegistry)
+        return super(Shell, self).updateConfiguration(myRegistry)
+
+
+    def run(self, *args, **kwds):
+
+        app = self.app
+
+        # build storage for the user input
+        registry = app.createRegistry()
+
+        # command line
+        argv = app.getArgv(*args, **kwds)
+        commandLine = app.processCommandline(registry, argv)
+        action = commandLine.action
+        app.argv = commandLine.processed
+        app.unprocessedArguments = commandLine.unprocessed
+
+        # curator
+        curator = app.createCurator()
+        app.initializeCurator(curator, registry)
         self.setCurator(curator)
-        curator.depositories += self.inventory.getDepositories()
+
+        # config context
+        context = app.newConfigContext()
+
+        # look for settings
         self.initializeConfiguration()
-        self.applyConfiguration()
+        self.inventory._priv_registry, app.inventory._priv_registry = self.filterConfiguration(self.inventory._priv_registry)
+
+        # read parameter files given on the command line
+        app.readParameterFiles(registry, context)
+
+        # give descendants an opportunity to collect input from other (unregistered) sources
+        app.collectUserInput(registry, context)
+
+        # split the configuration in two
+        registry, app.registry = self.filterConfiguration(registry)
+        self.registry = registry
+
+        # update user options from the command line
+        self.updateConfiguration(registry)
+
+        # transfer user input to my inventory
+        self.applyConfiguration(context)
+
+        # verify that my input did not contain any typos
+        if not context.verifyConfiguration('strict'):
+            import sys
+            sys.exit("%s: configuration error(s)" % self.name)
+
+        # initialize the trait cascade
         self.init()
 
         import sys
         if self.excepthook:
             sys.excepthook = self.excepthook.excepthook
 
-        app = ApplicationClass()
-        app.run(**kwds)
+        # initialize the application
+        app.updateConfiguration(app.registry)
+        app.applyConfiguration(context)
 
+        # verify that the application input did not contain any typos
+        if not app.verifyConfiguration(context, app.inventory.typos):
+            import sys
+            sys.exit("%s: configuration error(s)" % app.name)
+
+        app.init()
+
+        # print a startup page
+        app.generateBanner()
+
+        # the main application behavior
+        action = action and getattr(app, action)
+        if action:
+            action()
+        elif app._showHelpOnly:
+            pass
+        else:
+            message = kwds.get('message', 'execute')
+            method = getattr(app, message)
+            method(*args, **kwds)
+
+        # shutdown
+        app.fini()
+        self.fini()
+
         return
 
 

Modified: cs/pythia/trunk/pyre/applications/__init__.py
===================================================================
--- cs/pythia/trunk/pyre/applications/__init__.py	2007-02-08 23:55:18 UTC (rev 5987)
+++ cs/pythia/trunk/pyre/applications/__init__.py	2007-02-09 01:45:52 UTC (rev 5988)
@@ -36,8 +36,9 @@
     cls = kwds.get('applicationClass')
     kwds = dict(**kwds)
     kwds['argv'] = argv
-    shell = Shell()
-    shell.runApplication(cls, **kwds)
+    app = cls()
+    shell = Shell(app)
+    shell.run(**kwds)
     return 0
 
 

Modified: cs/pythia/trunk/pyre/hooks/ultraTB.odb
===================================================================
--- cs/pythia/trunk/pyre/hooks/ultraTB.odb	2007-02-08 23:55:18 UTC (rev 5987)
+++ cs/pythia/trunk/pyre/hooks/ultraTB.odb	2007-02-09 01:45:52 UTC (rev 5988)
@@ -32,7 +32,7 @@
 
         mode         = pyre.str("mode", default="Verbose")
         colorScheme  = pyre.str("color-scheme", default="Linux")
-        callPdb      = pyre.bool("call-pdb", default=True)
+        callPdb      = pyre.bool("call-pdb", default=False)
 
         callPdb.meta['tip'] = 'call pdb when an exception occurs'
 


Property changes on: cs/pythia/trunk/pythia.egg-info
___________________________________________________________________
Name: svn:ignore
   - SOURCES.txt
top_level.txt
PKG-INFO
not-zip-safe
dependency_links.txt

   + SOURCES.txt
top_level.txt
PKG-INFO
not-zip-safe
dependency_links.txt
requires.txt




More information about the cig-commits mailing list