Changeset 3002

Show
Ignore:
Timestamp:
06/14/08 16:12:05 (5 years ago)
Author:
nopper
Message:

Initial working
==========================
M umitGUI/App.py
M umitGUI/MainWindow.py
M umitCore/BasePaths.py
M umitCore/Paths.py
M umitCore/UserConf.py
M umitCore/UmitConf.py

Location:
branch/UmitPlugins
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • branch/UmitPlugins/umitCore/BasePaths.py

    r2986 r3002  
    4444ICONS_DIR = os.path.join(main_dir, "share", "icons", "umit") 
    4545PIXMAPS_DIR = os.path.join(main_dir, "share", "pixmaps", "umit") 
     46PLUGINS_DIR = os.path.join(main_dir, "share", "umit", "plugins") 
    4647DOCS_DIR = os.path.join(main_dir, "share", "doc", "umit") 
    4748 
     
    5859                  umit_opt = 'umit.opt', 
    5960                  pixmaps_dir = PIXMAPS_DIR, 
     61                  plugins_dir = PLUGINS_DIR, 
    6062                  i18n_dir = LOCALE_DIR, 
    6163                  i18n_message_file = 'umit.mo', 
  • branch/UmitPlugins/umitCore/Paths.py

    r2986 r3002  
    246246           and not exists(user_dir): 
    247247        mkdir(user_dir) 
     248        mkdir(join(user_dir, "plugins")) 
     249        mkdir(join(user_dir, "plugins-download")) 
    248250        log.debug(">>> Umit user dir successfully created! %s" % user_dir) 
    249251    else: 
  • branch/UmitPlugins/umitCore/UmitConf.py

    r2975 r3002  
    538538    not_present = property(get_not_present, set_not_present) 
    539539 
     540class Plugins(object): 
     541    def __init__(self): 
     542        self.parser = Path.config_parser 
     543        self.section_name = "plugins" 
     544 
     545        if not self.parser.has_section(self.section_name): 
     546            self.create_section() 
     547 
     548    def save_changes(self): 
     549        self.parser.save_changes() 
     550 
     551    def create_section(self): 
     552        from os.path import join 
     553        self.paths = [join(Path.config_dir, "plugins")] 
     554        self.plugins = "" 
     555 
     556    def __get_it(self, p_name): 
     557        value = None 
     558 
     559        try:     value = self.parser.get(self.section_name, p_name) 
     560        except:  pass 
     561        finally: return self.sanity_settings(value) 
     562 
     563    def __set_it(self, property_name, settings): 
     564        settings = self.sanity_settings(settings) 
     565        self.parser.set(self.section_name, property_name, settings) 
     566 
     567    def sanity_settings(self, settings): 
     568        # FIXME: more sensed :D 
     569        if not settings: 
     570            return "" 
     571        return settings 
     572 
     573    def get_paths(self): 
     574        return self.__get_it("paths").split(":") 
     575 
     576    def set_paths(self, settings): 
     577        self.__set_it("paths", ":".join(settings)) 
     578 
     579    def get_plugins(self): 
     580        return self.__get_it("plugins").split(":") 
     581 
     582    def set_plugins(self, settings): 
     583        self.__set_it("plugins", ":".join(settings)) 
     584 
     585    paths = property(get_paths, set_paths) 
     586    plugins = property(get_plugins, set_plugins) 
     587 
    540588# Exceptions 
    541589class ProfileNotFound: 
  • branch/UmitPlugins/umitCore/UserConf.py

    r2975 r3002  
    3939not_present = [58079, 19076, 12703] 
    4040modified = [63881, 42182, 13193] 
     41 
     42[plugins] 
     43paths = plugins 
    4144''' 
    4245 
     
    1851618519    return create_config_file(user_dir, 
    1851718520                              base_paths['config_file'], 
    18518                               umit_conf_content) 
     18521                              umit_conf_content % base_paths['plugins_dir']) 
    1851918522 
    1852018523def create_wizard(user_dir): 
  • branch/UmitPlugins/umitGUI/App.py

    r2986 r3002  
    3232from umitCore.UmitLogging import log 
    3333 
     34from umitPlugin.Engine import PluginEngine 
    3435 
    3536# Script found at http://www.py2exe.org/index.cgi/HowToDetermineIfRunningFromExe 
     
    4647class App: 
    4748    def __init__(self, args=sys.argv): 
    48         pass 
     49        # Initialite the PluginEngine 
     50        PluginEngine() 
    4951 
    5052    def __parse_cmd_line(self): 
     
    6163 
    6264        self.main_window.show_all() 
     65 
     66        # Load the selected plugins 
     67        PluginEngine().load_selected_plugins() 
    6368     
    6469    def safe_shutdown(self, signum, stack): 
  • branch/UmitPlugins/umitGUI/MainWindow.py

    r2980 r3002  
    5656from umitCore.UmitDB import Scans, UmitDB 
    5757 
     58from umitPlugin.Window import PluginWindow 
     59from umitPlugin.Engine import PluginEngine 
     60 
    5861root = False 
    5962try: 
     
    9396        self.set_title(_("Umit")) 
    9497 
     98        self._plugin_win = PluginWindow() 
    9599        self._icontheme = gtk.IconTheme() 
    96100        self.main_accel_group = gtk.AccelGroup() 
     
    227231                      _('Use the selected scan profile to create another'), 
    228232                      self._new_scan_profile_with_selected_cb), 
     233                       
     234                      ('Extensions', 
     235                       gtk.STOCK_INFO, 
     236                       _('_Extensions'), 
     237                       '<Control>e', 
     238                       _('Extensions manager'), 
     239                       self._show_plugin_manager), 
    229240 
    230241                      ('Quit', 
     
    298309            <menuitem action='Compare Results'/> 
    299310            <menuitem action='Search Scan'/> 
     311            <separator/> 
     312            <menuitem action='Extensions'/> 
    300313            </menu> 
    301314 
     
    357370                                  title=results[result][1].scan_name) 
    358371                page.status.set_search_loaded() 
    359  
     372     
     373    def _show_plugin_manager(self, widget, data=None): 
     374        self._plugin_win.show() 
     375     
    360376    def _close_scan_cb(self, widget, data=None): 
    361377        # data can be none, if the current page is to be closed 
     
    9891005            UmitDB().cleanup(SearchConfig().converted_save_time) 
    9901006 
     1007            # Saving the plugins 
     1008            PluginEngine().plugins.save_changes() 
     1009 
    9911010            gtk.main_quit() 
    9921011