updated PluginStatus dialog

svn: r6390
This commit is contained in:
Don Allingham 2006-04-21 17:08:34 +00:00
parent e6d9cb2bf1
commit 8243bb1079
8 changed files with 34 additions and 77 deletions

View File

@ -1,3 +1,12 @@
2006-04-21 Don Allingham <don@gramps-project.org>
* src/ViewManager.py: start of cleaned up plugin manager
* src/Errors.py: warning error for unavailable plugin
* src/PluginUtils/__init__.py: start of cleaned up plugin manager
* src/PluginUtils/_Plugins.py: start of cleaned up plugin manager
* src/PluginUtils/_PluginMgr.py: start of cleaned up plugin manager
* src/docgen/PdfDoc.py: Issue unavailable error on reportlab failure
* src/docgen/LPRDoc.py: Issue unavailable error on gnomeprint failure
2006-04-20 Don Allingham <don@gramps-project.org>
* src/DataViews/_EventView.py: pychecker fixes
* src/ViewManager.py: call scratchpad properly

View File

@ -120,3 +120,11 @@ class WindowActiveError(Exception):
def __str__(self):
return self.value
class UnavailableError(Exception):
def __init__(self,value):
Exception.__init__(self)
self.value = value
def __str__(self):
return self.value

View File

@ -65,7 +65,7 @@ bkitems_list = []
cl_list = []
cli_tool_list = []
_success_list = []
success_list = []
#-------------------------------------------------------------------------
#
@ -90,11 +90,11 @@ _unavailable = _("No description was provided"),
def load_plugins(direct):
"""Searches the specified directory, and attempts to load any python
modules that it finds, adding name to the attempt_lists list. If the module
successfully loads, it is added to the _success_list list. Each plugin is
successfully loads, it is added to the success_list list. Each plugin is
responsible for registering itself in the correct manner. No attempt
is done in this routine to register the tasks."""
global _success_list,attempt_list,loaddir_list,failmsg_list
global success_list,attempt_list,loaddir_list,failmsg_list
# if the directory does not exist, do nothing
if not os.path.isdir(direct):
@ -113,7 +113,7 @@ def load_plugins(direct):
# loop through each file in the directory, looking for files that
# have a .py extention, and attempt to load the file. If it succeeds,
# add it to the _success_list list. If it fails, add it to the _failure
# add it to the success_list list. If it fails, add it to the _failure
# list
for filename in os.listdir(direct):
@ -125,7 +125,7 @@ def load_plugins(direct):
plugin = match.groups()[0]
try:
a = __import__(plugin)
_success_list.append(a)
success_list.append((filename,a))
except Errors.PluginError, msg:
expect_list.append((filename,str(msg)))
except:

View File

@ -297,73 +297,6 @@ class ToolPlugins(PluginDialog):
_("Run selected tool"),
TOOLS)
#-------------------------------------------------------------------------
#
# PluginStatus
#
#-------------------------------------------------------------------------
class PluginStatus(ManagedWindow.ManagedWindow):
"""Displays a dialog showing the status of loaded plugins"""
def __init__(self,state,uistate,track):
import cStringIO
ManagedWindow.ManagedWindow.__init__(self, uistate, [], None)
self.state = state
self.uistate = uistate
self.glade = gtk.glade.XML(const.plugins_glade,"plugstat","gramps")
self.window = self.glade.get_widget("plugstat")
self.window.set_title("%s - GRAMPS" % _('Plugin status'))
window = self.glade.get_widget("text")
self.pop_button = self.glade.get_widget("pop_button")
self.pop_button.set_active(Config.get_pop_plugin_status())
self.pop_button.connect('toggled',
lambda obj: Config.save_pop_plugin_status(self.pop_button.get_active()))
Config.client.notify_add("/apps/gramps/behavior/pop-plugin-status",
self.pop_button_update)
self.glade.signal_autoconnect({
'on_close_clicked' : self.close,
'on_help_clicked' : self.help,
'on_plugstat_delete_event' : self.on_delete,
})
info = cStringIO.StringIO()
if len(_PluginMgr.expect_list) + len(_PluginMgr.failmsg_list) == 0:
window.get_buffer().set_text(_('All modules were successfully loaded.'))
else:
info.write(_("The following modules could not be loaded:"))
info.write("\n\n")
for (filename,msg) in _PluginMgr.expect_list:
info.write("%s: %s\n\n" % (filename,msg))
for (filename,msgs) in _PluginMgr.failmsg_list:
error = str(msgs[0])
if error[0:11] == "exceptions.":
error = error[11:]
info.write("%s: %s\n" % (filename,error) )
traceback.print_exception(msgs[0],msgs[1],msgs[2],None,info)
info.write('\n')
info.seek(0)
window.get_buffer().set_text(info.read())
def on_delete(self,obj1,obj2):
pass
def close(self,obj):
self.window.destroy()
def help(self,obj):
"""Display the GRAMPS manual"""
GrampsDisplay.help('gramps-getting-started')
def pop_button_update(self, client,cnxn_id,entry,data):
self.pop_button.set_active(Config.get_pop_plugin_status())
#-------------------------------------------------------------------------
#
# Building pulldown menus

View File

@ -35,3 +35,4 @@ import _ReportOptions as ReportOptions
import _ReportUtils as ReportUtils
import _Tool as Tool
import _Plugins as Plugins
import _PluginStatus as PluginStatus

View File

@ -59,7 +59,7 @@ import gobject
# GRAMPS modules
#
#-------------------------------------------------------------------------
from PluginUtils import Plugins, Report, Tool, \
from PluginUtils import Plugins, Report, Tool, PluginStatus, \
relationship_class, load_plugins, \
import_list, tool_list, report_list
import DisplayState
@ -383,7 +383,7 @@ class ViewManager:
error |= load_plugins(const.pluginsDir)
error |= load_plugins(os.path.join(const.home_dir, "plugins"))
if Config.get_pop_plugin_status() and error:
Plugins.PluginStatus(self.state, self.uistate, [])
PluginStatus.PluginStatus(self.state, self.uistate, [])
self.uistate.push_message(_('Ready'))
def quit(self, obj=None):
@ -460,7 +460,7 @@ class ViewManager:
def plugin_status(self, obj):
"""Display Tip of the day"""
Plugins.PluginStatus(self.state, self.uistate, [])
PluginStatus.PluginStatus(self.state, self.uistate, [])
def about(self, obj):
about = gtk.AboutDialog()

View File

@ -42,7 +42,12 @@ from gettext import gettext as _
#
#------------------------------------------------------------------------
import gtk.gdk
import gnomeprint, gnomeprint.ui
try:
import gnomeprint, gnomeprint.ui
except ImportError:
raise Errors.UnavailableError(_("Cannot be loaded because python bindinds for GNOME print are not installed"))
### FIXME ###
if gnomeprint.Context.__dict__.has_key('grestore'):

View File

@ -73,8 +73,9 @@ try:
for faceName in reportlab.pdfbase.pdfmetrics.standardFonts:
reportlab.pdfbase.pdfmetrics.registerTypeFace(
reportlab.pdfbase.pdfmetrics.TypeFace(faceName))
except ImportError:
raise Errors.PluginError( _("The ReportLab modules are not installed"))
raise Errors.UnavailableError(_("Cannot be loaded because ReportLab is not installed"))
#------------------------------------------------------------------------
#