[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.7, Fri Jan 7 14:40:33 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          try:          try:
103              #b = BssFactory('biosimscratch/bss@db02', 'oracle' )              #nb: making them auto registeres them in catalog
104              #b = BssFactory('pgsql.mcs.anl.gov:5432:kahdb:trust:inme', "postgres")  
105              #b = BssFactory('porta-video:5432:KahSCDb:trust:inme', "postgres")              df   = KahDbDataFactory( ddf, ddft )
106              b = BssFactory('fl-gentoo-test:5432:KahSCDb:trust:inme', "postgres")              chem = KahChemDbDataFactory( dchem, dchemt )
107              Catalog.instance().addDataFactory( b)  
108          except NotImplementedError:          except NotImplementedError:
109              pass              pass
110    
111          return          return
112    
113        #------------------------------------------------------------------------
114        def doInitialPlugins(self):
115        #------------------------------------------------------------------------
116    
117            cfg    = self.configMgr.getSection( "ModelEditor" )
118    
119            pluginList = cfg.getStringList("PluginList")
120            for p in pluginList:
121                print "trying to get plugin named: ", p
122    
123                try:
124                    self.mainMenuBar.doAddPlugIn( p )
125                except ImportError, e:
126                    print "Could not import %s: %s" % (p, e)
127                except LookupError:
128                    print "No register hook called 'register' found in plugin"
129    
130            return
131    
132        #------------------------------------------------------------------------
133      def error( self, message):      def error( self, message):
134        #------------------------------------------------------------------------
135          dlg = wxMessageDialog(self, message, style=wxOK)          dlg = wxMessageDialog(self, message, style=wxOK)
136          dlg.ShowModal()          dlg.ShowModal()
137          dlg.Destroy()          dlg.Destroy()
138          return          return
139    
140        #------------------------------------------------------------------------
141        def signalHandler(self, signum, frame):
142        #------------------------------------------------------------------------
143            """
144            signal handler for sigint, sigterm, and sigHUP to let us close down cleanly.
145            We need to disconnect from AG.
146            """
147    
148            print "ModelEditor:signalHandler: caught signal=", signum
149    
150            try:
151                theMgr = self.cat.meAGMgr
152                if (not theMgr == None):
153                    theMgr.done()
154            except Exception, e:
155                print e
156    
157            self.mainMenuBar.exitApp(None)
158            return
159    
160    
161  ########################################################################  ########################################################################
162  if __name__ == "__main__":  if __name__ == "__main__":
163      app = MyApp(0)      app = MyApp(0)

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3