Changeset 465 for trunk/pyragua/pyragua.py – Pyragua

Changeset 465 for trunk/pyragua/pyragua.py

Show
Ignore:
Timestamp:
08/09/10 02:15:01 (22 months ago)
Author:
ogranada
Message:

2010-08-09 Oscar Andres Granada <ogranada@…>

  • The Plugin architecture are implemented in pyragua.py file
  • Many methods were added to make more orderly implementation
  • The option parser are added and add the options "-s" (not Splash) and "-d" (debug)
  • yapsy library were modified in the file PluginManager?.py that without this amendment would be

required to install the library on the system.

  • They have positioned sample plugins in the plugins folder, it is necessary to improve the

documentation about this.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pyragua/pyragua.py

    r458 r465  
    1616 
    1717from ui import mainwindow 
     18import wx  
     19# imports required by the splash and plugins. 
     20from shared import gaugesplash 
     21from os import getcwd, path, system 
     22from user import home as userhome 
     23 
    1824 
    1925class Pyragua(object): 
     
    2127    """ 
    2228    def __init__(self): 
    23         self.main_window = mainwindow.MainWindow() 
     29        self.__opt_manage() 
     30        self.main_window = mainwindow.MainWindow()      
    2431        self.main_window.pyragua = self 
    2532 
    2633    def start(self): 
     34        self.__start() 
    2735        self.main_window.show() 
    2836        self.main_window.start()  # The wx main loop gets started 
     37         
     38    def __opt_manage(self): 
     39        ''' 
     40        Destined for add the command line options 
     41        ''' 
     42        from modparser import ModParser 
     43        self.__modparser = ModParser({'opt':'-s','large_opt':'--has-splash','default':True,'action':"store_false"}, 
     44                                     {'opt':'-d','large_opt':'--debug','default':False,'action':"store_true"})         
     45         
     46    def __start(self): 
     47        ''' 
     48            Run the IDE with the data of the options. 
     49        ''' 
     50        if self.__modparser.get('has_splash') not in ['no', 'No', None, 'false', 'FALSE', 'False',False]: 
     51            splash = gaugesplash.GaugeSplash(getcwd()+'/img/pyragua_splash.png') 
     52            splash.Show() 
     53            splash.Update() 
     54            wx.Yield() 
     55        else: 
     56            splash = None 
     57        if self.__modparser.get('debug'): 
     58            globals()['debug']=True 
     59        else: 
     60            globals()['debug']=False 
     61        # loads 
     62        self.__load(splash) 
     63        #end loads 
     64        if splash != None: 
     65            splash.Destroy() 
     66        wx.GetApp().Yield() 
     67         
     68    def __load(self, splash=None): 
     69        import shared 
     70        from shared.yapsy.PluginManager import PluginManager 
     71        from shared.yapsy.IPlugin import IPlugin 
     72        pm = PluginManager() 
     73        if not path.exists(getcwd()+'/pyragua'): 
     74            system('mkdir %s'%(getcwd()+'/pyragua')) 
     75        if not path.exists(getcwd()+'/pyragua/plugins'): 
     76            system('mkdir %s'%(getcwd()+'/pyragua/plugins')) 
     77        if not path.exists(userhome+'/.pyragua'): 
     78            system('mkdir %s'%(userhome+'/.pyragua')) 
     79        if not path.exists(userhome+'/.pyragua/plugins'): 
     80            system('mkdir %s'%(userhome+'/.pyragua/plugins')) 
     81        pm.setPluginPlaces([getcwd()+'/pyragua/plugins',userhome+'/.pyragua/plugins'])         
     82        pm.locatePlugins() 
     83        pm.loadPlugins(candidate_globals={'IPlugin':IPlugin}) 
     84        pluginList = pm.getPluginsOfCategory("Default") 
     85          
     86        #============================ 
     87        if splash != None: 
     88            from time import sleep 
     89            count = len(pluginList) 
     90            splash.setTicks(count)         
     91            for i in range(count):                 
     92                item=pluginList[i] 
     93                if globals()['debug']: 
     94                    print "Load: ", 
     95                    print item.name 
     96                pluginobject = item.plugin_object 
     97                try: 
     98                    pluginobject.run(self.main_window) 
     99                except: 
     100                    pass 
     101                splash.tick("Loading %s" % item.name) 
     102                sleep(.1) 
     103        #============================ 
    29104 
    30105    def stop(self):