[Bio] / ModelEditor / ModelEditor Repository:
ViewVC logotype

Diff of /ModelEditor/ModelEditor

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3, Tue Nov 2 17:48:26 2004 UTC revision 1.8, Mon Jan 31 16:52:09 2005 UTC
# Line 1  Line 1 
1  #!/usr/bin/env python  #!/usr/bin/env python
2    
3    #import signal
4  from wxPython.wx import *  from wxPython.wx import *
5    
6    from KahApp.KahConfigMgr import KahConfigMgr
7  from ModelEditor.MainLayout        import MainLayout  from ModelEditor.MainLayout        import MainLayout
8  from ModelEditor.RXpanel           import RXPanel  from ModelEditor.RXpanel           import RXPanel
9  from ModelEditor.RecoElempanel     import RecoElempanel  from ModelEditor.RecoElempanel     import RecoElempanel
# Line 11  Line 13 
13  from ModelEditor.HelpPanel         import HelpPanel  from ModelEditor.HelpPanel         import HelpPanel
14  from ModelEditor.FontManager       import FontManager  from ModelEditor.FontManager       import FontManager
15  from ModelEditor.MainMenuBar       import MainMenuBar  from ModelEditor.MainMenuBar       import MainMenuBar
16  from FaST.BssFactory         import BssFactory  from KahChemDb.KahChemDbDataFactory import KahChemDbDataFactory
17    from KahDataServices.KahDbDataFactory  import KahDbDataFactory
18  from CatalogServices.Catalog import Catalog  from CatalogServices.Catalog import Catalog
19    
20  #need to change panel to Panel. lower case panel is already in cvs.  #need to change panel to Panel. lower case panel is already in cvs.
# Line 33  Line 36 
36          #self.factoryMgr = None          #self.factoryMgr = None
37          MainLayout.__init__(self, *args, **kwds)          MainLayout.__init__(self, *args, **kwds)
38    
39            self.configMgr = KahConfigMgr()
40            self.setupConfig()
41    
42          self.rootId        = None        # root ID for recoelem tree.  why here??          self.rootId        = None        # root ID for recoelem tree.  why here??
43          self.catalogRootId = None        # root ID for catalog tree.          self.catalogRootId = None        # root ID for catalog tree.
44          self.fontManager    = FontManager(self)          self.fontManager    = FontManager(self)
# Line 47  Line 53 
53    
54          EVT_CLOSE(self, self.mainMenuBar.exitApp)          EVT_CLOSE(self, self.mainMenuBar.exitApp)
55    
56            #signal.signal(signal.SIGINT, self.signalHandler)
57            #signal.signal(signal.SIGTERM, self.signalHandler)
58            #signal.signal(signal.SIGHUP, self.signalHandler)
59    
60            self.doDefaultDataFactories()
61            self.doInitialPlugins()
62    
63            return
64    
65        #------------------------------------------------------------------------
66        def getConfigMgr( self ):
67        #------------------------------------------------------------------------
68            return self.configMgr
69    
70        #------------------------------------------------------------------------
71        def setupConfig( self ):
72        #------------------------------------------------------------------------
73    
74            # Config ourselves.  Unusual usage of configMgr.
75    
76            self.configMgr.newSection( "ModelEditor" )
77            cfg = self.configMgr.getSection( "ModelEditor" )
78    
79            cfg.regString( "DefaultDataFactory", "kahchoo/bss@db02" )
80            cfg.regString( "DefaultDataFactoryDbType", "oracle" )
81            cfg.regString( "DefaultChemDb", "pgsql:5432:kahdb:trust:inme" )
82            cfg.regString( "DefaultChemDbType", "postgres" )
83            cfg.regStringList( "PluginList", [] )
84    
85            # now load the config
86    
87            self.configMgr.loadConfigFile( "ModelEditor.cfg" )
88            self.configMgr.dump()
89            return
90    
91    
92        #------------------------------------------------------------------------
93        def doDefaultDataFactories(self):
94        #------------------------------------------------------------------------
95    
96            cfg    = self.configMgr.getSection( "ModelEditor" )
97            ddf    =  cfg.getString("DefaultDataFactory")
98            ddft   = cfg.getString( "DefaultDataFactoryDbType")
99            dchem  = cfg.getString( "DefaultChemDb")
100            dchemt = cfg.getString( "DefaultChemDbType")
101    
102            # nb: making these datafactories auto registeres them in catalog
103          try:          try:
104              #b = BssFactory('biosimscratch/bss@db02', 'oracle' )              df   = KahDbDataFactory( ddf, ddft )
105              #b = BssFactory('pgsql.mcs.anl.gov:5432:kahdb:trust:inme', "postgres")          except NotImplementedError:
106              #b = BssFactory('porta-video:5432:KahSCDb:trust:inme', "postgres")              pass
107              b = BssFactory('fl-gentoo-test:5432:KahSCDb:trust:inme', "postgres")  
108              Catalog.instance().addDataFactory( b)          try:
109                chem = KahChemDbDataFactory( dchem, dchemt )
110          except NotImplementedError:          except NotImplementedError:
111              pass              pass
112    
113          return          return
114    
115        #------------------------------------------------------------------------
116        def doInitialPlugins(self):
117        #------------------------------------------------------------------------
118    
119            cfg    = self.configMgr.getSection( "ModelEditor" )
120    
121            pluginList = cfg.getStringList("PluginList")
122            for p in pluginList:
123                print "trying to get plugin named: ", p
124    
125                try:
126                    self.mainMenuBar.doAddPlugIn( p )
127                except ImportError, e:
128                    print "Could not import %s: %s" % (p, e)
129                except LookupError:
130                    print "No register hook called 'register' found in plugin"
131    
132            return
133    
134        #------------------------------------------------------------------------
135      def error( self, message):      def error( self, message):
136        #------------------------------------------------------------------------
137          dlg = wxMessageDialog(self, message, style=wxOK)          dlg = wxMessageDialog(self, message, style=wxOK)
138          dlg.ShowModal()          dlg.ShowModal()
139          dlg.Destroy()          dlg.Destroy()
140          return          return
141    
142        #------------------------------------------------------------------------
143        def signalHandler(self, signum, frame):
144        #------------------------------------------------------------------------
145            """
146            signal handler for sigint, sigterm, and sigHUP to let us close down cleanly.
147            We need to disconnect from AG.
148            """
149    
150            print "ModelEditor:signalHandler: caught signal=", signum
151    
152            try:
153                theMgr = self.cat.meAGMgr
154                if (not theMgr == None):
155                    theMgr.done()
156            except Exception, e:
157                print e
158    
159            self.mainMenuBar.exitApp(None)
160            return
161    
162    
163  ########################################################################  ########################################################################
164  if __name__ == "__main__":  if __name__ == "__main__":
165      app = MyApp(0)      app = MyApp(0)

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.8

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3