def load_plugins(self):
self.plugins = []
+ self.commands = []
for plugin_name,include in self.config.items('plugins'):
if include == 'True':
plugin = plugin_mod.PLUGINS[plugin_name]
except configparser.NoSectionError:
pass
self.plugins.append(plugin_mod.PLUGINS[plugin_name])
+ self.commands.extend(plugin.commands())
def load_drivers(self):
self.drivers = []
if self.config.changed:
self.config.write() # Does not preserve original comments
-# #define the list of active drivers
-# self.drivers = []
-# for driver in self.config['drivers']:
-# if self.config['drivers'][driver]:
-# #get the corresponding filename and path
-# filename = ''.join([driver, '.py'])
-# path = lh.get_file_path(filename, ['drivers'])
-# #the driver is active for driver[1] == 1
-# if os.path.isfile(path):
-# #driver files are located in the 'drivers' subfolder
-# driver_name = ''.join(['drivers.', driver])
-# module = __import__(driver_name)
-# class_file = getattr(drivers, driver)
-# for command in dir(class_file):
-# if command.endswith('Driver'):
-# self.drivers.append(getattr(class_file, command))
-# #import all active plugins and plotmanips
-# #the plotmanip_functions contains: {the name of the plotmanip: [method, class_object]}
-# plotmanip_functions = {}
-# #add 'general.ini' to self.configs (this is not a plugin and thus must be imported seperately)
-# ini_path = lh.get_file_path('general.ini', ['plugins'])
-# plugin_config = ConfigObj(ini_path)
-# #self.config.merge(plugin_config)
-# self.configs['general'] = plugin_config
-# #make sure we execute _plug_init() for every command line plugin we import
-# for plugin in self.config['plugins']:
-# if self.config['plugins'][plugin]:
-# filename = ''.join([plugin, '.py'])
-# path = lh.get_file_path(filename, ['plugins'])
-# if os.path.isfile(path):
-# #get the corresponding filename and path
-# plugin_name = ''.join(['plugins.', plugin])
-# try:
-# #import the module
-# module = __import__(plugin_name)
-# #prepare the ini file for inclusion
-# ini_path = path.replace('.py', '.ini')
-# #include ini file
-# plugin_config = ConfigObj(ini_path)
-# #self.config.merge(plugin_config)
-# self.configs[plugin] = plugin_config
-# #add to plugins
-# commands = eval('dir(module.' + plugin+ '.' + plugin + 'Commands)')
-# #keep only commands (ie names that start with 'do_')
-# commands = [command for command in commands if command.startswith('do_')]
-# if commands:
-# self.plugins[plugin] = commands
-# try:
-# #initialize the plugin
-# eval('module.' + plugin+ '.' + plugin + 'Commands._plug_init(self)')
-# except AttributeError:
-# pass
-# except ImportError:
-# pass
-# #initialize the commands tree
-# commands = dir(HookeFrame)
-# commands = [command for command in commands if command.startswith('do_')]
-# if commands:
-# self.plugins['general'] = commands
-# self.panelCommands.Initialize(self.plugins)
-# for command in dir(self):
-# if command.startswith('plotmanip_'):
-# plotmanip_functions[command] = [command, getattr(self, command)]
-# for name in self.config['plotmanipulators']['names']:
-# if self.config['plotmanipulators'].as_bool(name):
-# command_name = ''.join(['plotmanip_', name])
-# if command_name in plotmanip_functions:
-# self.plotmanipulators.append(plotmanip_functions[command_name])
-# #load default list, if possible
-# self.do_loadlist(self.config['general']['list'])
-#
-# def _BindEvents(self):
-# self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
-# self.Bind(wx.EVT_SIZE, self.OnSize)
-# self.Bind(wx.EVT_CLOSE, self.OnClose)
-# # Show How To Use The Closing Panes Event
-# self.Bind(aui.EVT_AUI_PANE_CLOSE, self.OnPaneClose)
-# self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnNotebookPageClose)
-# #menu
-# self.Bind(wx.EVT_MENU, self.OnClose, id=wx.ID_EXIT)
-# self.Bind(wx.EVT_MENU, self.OnAbout, id=wx.ID_ABOUT)
-# #view
-# self.Bind(wx.EVT_MENU_RANGE, self.OnView, id=ID_ViewAssistant, id2=ID_ViewResults)
-# #perspectives
-# self.Bind(wx.EVT_MENU, self.OnDeletePerspective, id=ID_DeletePerspective)
-# self.Bind(wx.EVT_MENU, self.OnSavePerspective, id=ID_SavePerspective)
-# self.Bind(wx.EVT_MENU_RANGE, self.OnRestorePerspective, id=ID_FirstPerspective, id2=ID_FirstPerspective+1000)
-# #toolbar
-# self.Bind(wx.EVT_TOOL, self.OnExportImage, id=ID_ExportImage)
-# self.Bind(wx.EVT_TOOL, self.OnNext, id=ID_Next)
-# self.Bind(wx.EVT_TOOL, self.OnPrevious, id=ID_Previous)
-# #self.Bind(.EVT_AUITOOLBAR_TOOL_DROPDOWN, self.OnDropDownToolbarItem, id=ID_DropDownToolbarItem)
-# #dir control
-# treeCtrl = self.panelFolders.GetTreeCtrl()
-# #tree.Bind(wx.EVT_LEFT_UP, self.OnDirCtrl1LeftUp)
-# #tree.Bind(wx.EVT_LEFT_DOWN, self.OnGenericDirCtrl1LeftDown)
-# treeCtrl.Bind(wx.EVT_LEFT_DCLICK, self.OnDirCtrlLeftDclick)
-# #playlist tree
-# self.panelPlaylists.PlaylistsTree.Bind(wx.EVT_LEFT_DOWN, self.OnPlaylistsLeftDown)
-# self.panelPlaylists.PlaylistsTree.Bind(wx.EVT_LEFT_DCLICK, self.OnPlaylistsLeftDclick)
-# #commands tree
-# self.panelCommands.ExecuteButton.Bind(wx.EVT_BUTTON, self.OnExecute)
-# self.panelCommands.CommandsTree.Bind(wx.EVT_LEFT_DOWN, self.OnTreeCtrlCommandsLeftDown)
-# #property editor
-# self.panelProperties.pg.Bind(wxpg.EVT_PG_CHANGED, self.OnPropGridChanged)
-# self.panelProperties.pg.Bind(wxpg.EVT_PG_SELECTED, self.OnPropGridSelect)
-# #results panel
-# self.panelResults.results_list.OnCheckItem = self.OnResultsCheck
-#
# def _GetActiveCurveIndex(self):
# playlist = self.GetActivePlaylist()
# #get the selected item from the tree