[Bio] / ModelEditor / ModelEditor Repository:
ViewVC logotype

Diff of /ModelEditor/ModelEditor

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

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

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.9

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3