* src/Plugins.py: Remove redundant list of failed plugins.

Properly reload plugins. Work around what seems to be a Python bug.
Allow setting the preference for showing up the plugin status
upon load/reload if problems are detected. Support Help button.
Automatically close old status window when new one is opened.
* src/plugins.glade: Add Help button and the check button.
* src/data/gramps.schemas: Add pop-plugin-status key.
* src/GrampsGconfKeys.py: Add get/save methods for new key.
* src/*.gladep: Remove from CVS.
* src/plugins/IndivComplete.py: Typo.
* src/plugins/Partition.py: Comment out wrong class instantiation.
This plugin is dysfunctional, and we should either remove it or
fix it.


svn: r3743
This commit is contained in:
Alex Roitman 2004-11-20 04:46:47 +00:00
parent f4f060f34b
commit d1bdabf5fc
7 changed files with 161 additions and 20 deletions

View File

@ -1,3 +1,18 @@
2004-11-19 Alex Roitman <shura@alex.neuro.umn.edu>
* src/Plugins.py: Remove redundant list of failed plugins.
Properly reload plugins. Work around what seems to be a Python bug.
Allow setting the preference for showing up the plugin status
upon load/reload if problems are detected. Support Help button.
Automatically close old status window when new one is opened.
* src/plugins.glade: Add Help button and the check button.
* src/data/gramps.schemas: Add pop-plugin-status key.
* src/GrampsGconfKeys.py: Add get/save methods for new key.
* src/*.gladep: Remove from CVS.
* src/plugins/IndivComplete.py: Typo.
* src/plugins/Partition.py: Comment out wrong class instantiation.
This plugin is dysfunctional, and we should either remove it or
fix it.
2004-11-18 Don Allingham <dallingham@users.sourceforge.net> 2004-11-18 Don Allingham <dallingham@users.sourceforge.net>
* src/ColumnOrder.py: pychecker fixes * src/ColumnOrder.py: pychecker fixes
* src/DateParser.py: pychecker fixes * src/DateParser.py: pychecker fixes

View File

@ -200,6 +200,12 @@ def get_usetips():
def save_usetips(val): def save_usetips(val):
set_bool("/apps/gramps/behavior/use-tips",val) set_bool("/apps/gramps/behavior/use-tips",val)
def get_pop_plugin_status():
return get_bool("/apps/gramps/behavior/pop-plugin-status")
def save_pop_plugin_status(val):
set_bool("/apps/gramps/behavior/pop-plugin-status",val)
# preferences keys # preferences keys
def get_person_id_prefix(): def get_person_id_prefix():
return get_string("/apps/gramps/preferences/iprefix") return get_string("/apps/gramps/preferences/iprefix")

View File

@ -36,6 +36,7 @@ importers, exporters, and document generators.
import gobject import gobject
import gtk import gtk
import gtk.glade import gtk.glade
import gnome
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -72,7 +73,6 @@ _tools = []
_imports = [] _imports = []
_exports = [] _exports = []
_success = [] _success = []
_failed = []
_expect = [] _expect = []
_attempt = [] _attempt = []
_loaddir = [] _loaddir = []
@ -82,6 +82,7 @@ _drawdoc = []
_failmsg = [] _failmsg = []
_bkitems = [] _bkitems = []
_status_up = None
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Default relationship calculator # Default relationship calculator
@ -326,14 +327,30 @@ class PluginStatus:
"""Displays a dialog showing the status of loaded plugins""" """Displays a dialog showing the status of loaded plugins"""
def __init__(self): def __init__(self):
global _status_up
if _status_up:
_status_up.close(None)
_status_up = self
import cStringIO import cStringIO
self.glade = gtk.glade.XML(const.pluginsFile,"plugstat","gramps") self.glade = gtk.glade.XML(const.pluginsFile,"plugstat","gramps")
self.top = self.glade.get_widget("plugstat") self.top = self.glade.get_widget("plugstat")
self.top.set_title("%s - GRAMPS" % _('Plugin status')) self.top.set_title("%s - GRAMPS" % _('Plugin status'))
window = self.glade.get_widget("text") window = self.glade.get_widget("text")
self.pop_button = self.glade.get_widget("pop_button")
if GrampsGconfKeys.get_pop_plugin_status():
self.pop_button.set_active(1)
else:
self.pop_button.set_active(0)
self.pop_button.connect('toggled',
lambda obj: GrampsGconfKeys.save_pop_plugin_status(self.pop_button.get_active()))
GrampsGconfKeys.client.notify_add("/apps/gramps/behavior/pop-plugin-status",
self.pop_button_update)
self.glade.signal_autoconnect({ self.glade.signal_autoconnect({
'on_close_clicked' : self.close 'on_close_clicked' : self.close,
'on_help_clicked' : self.help,
'on_plugstat_delete_event' : self.on_delete,
}) })
info = cStringIO.StringIO() info = cStringIO.StringIO()
@ -357,8 +374,19 @@ class PluginStatus:
info.seek(0) info.seek(0)
window.get_buffer().set_text(info.read()) window.get_buffer().set_text(info.read())
def on_delete(self,obj1,obj2):
_status_up = None
def close(self,obj): def close(self,obj):
self.top.destroy() self.top.destroy()
_status_up = None
def help(self,obj):
"""Display the GRAMPS manual"""
gnome.help_display('gramps-manual','gramps-getting-started')
def pop_button_update(self, client,cnxn_id,entry,data):
self.pop_button.set_active(GrampsGconfKeys.get_pop_plugin_status())
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -372,7 +400,7 @@ def load_plugins(direct):
responsible for registering itself in the correct manner. No attempt responsible for registering itself in the correct manner. No attempt
is done in this routine to register the tasks.""" is done in this routine to register the tasks."""
global _success,_failed,_attempt,_loaddir global _success,_attempt,_loaddir,_failmsg
# if the directory does not exist, do nothing # if the directory does not exist, do nothing
if not os.path.isdir(direct): if not os.path.isdir(direct):
@ -409,33 +437,53 @@ def load_plugins(direct):
except: except:
_failmsg.append((filename,sys.exc_info())) _failmsg.append((filename,sys.exc_info()))
if GrampsGconfKeys.get_pop_plugin_status() and len(_expect)+len(_failmsg):
PluginStatus()
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# reload_plugins # reload_plugins
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def reload_plugins(obj): def reload_plugins(obj=None,junk1=None,junk2=None,junk3=None):
"""Treated as a callback, causes all plugins to get reloaded. This is """Treated as a callback, causes all plugins to get reloaded. This is
useful when writing and debugging a plugin""" useful when writing and debugging a plugin"""
pymod = compile(r"^(.*)\.py$") pymod = compile(r"^(.*)\.py$")
# attempt to reload all plugins that have succeeded global _success,_attempt,_loaddir,_failmsg
# in the past
oldfailmsg = _failmsg[:]
_failmsg = []
# attempt to reload all plugins that have succeeded in the past
for plugin in _success: for plugin in _success:
filename = os.path.basename(plugin.__file__)
filename = filename.replace('pyc','py')
filename = filename.replace('pyo','py')
try: try:
reload(plugin) reload(plugin)
except: except:
_failmsg.append((plugin,sys.exc_info())) _failmsg.append((filename,sys.exc_info()))
# attempt to load the plugins that have failed in the past # attempt to load the plugins that have failed in the past
for plugin in _failed: for (filename,message) in oldfailmsg:
name = os.path.split(filename)
match = pymod.match(name[1])
if not match:
continue
_attempt.append(filename)
plugin = match.groups()[0]
try: try:
__import__(plugin) # For some strange reason second importing of a failed plugin
del _failmsg[plugin] # results in success. Then reload reveals the actual error.
# Looks like a bug in Python.
a = __import__(plugin)
reload(a)
_success.append(a)
except: except:
_failmsg.append((plugin,sys.exc_info())) _failmsg.append((filename,sys.exc_info()))
# attempt to load any new files found # attempt to load any new files found
for directory in _loaddir: for directory in _loaddir:
@ -445,7 +493,7 @@ def reload_plugins(obj):
if not match: if not match:
continue continue
if filename in _attempt: if filename in _attempt:
return continue
_attempt.append(filename) _attempt.append(filename)
plugin = match.groups()[0] plugin = match.groups()[0]
try: try:
@ -455,6 +503,14 @@ def reload_plugins(obj):
except: except:
_failmsg.append((filename,sys.exc_info())) _failmsg.append((filename,sys.exc_info()))
if GrampsGconfKeys.get_pop_plugin_status():
global _status_up
if len(_failmsg):
PluginStatus()
elif _status_up:
_status_up.close(None)
_status_up = None
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Plugin registering # Plugin registering
@ -765,3 +821,15 @@ def get_draw_doc_menu(main_menu,callback=None,obj=None):
callback(menuitem) callback(menuitem)
index = index + 1 index = index + 1
main_menu.set_menu(myMenu) main_menu.set_menu(myMenu)
#-------------------------------------------------------------------------
#
# Register the plugin reloading tool
#
#-------------------------------------------------------------------------
register_tool(
reload_plugins,
_("Reload plugins"),
category=_("Debug"),
description=_("Attempt to reload plugins. Note: This tool itself is not reloaded!"),
)

View File

@ -552,6 +552,19 @@
</locale> </locale>
</schema> </schema>
<schema>
<key>/schemas/apps/gramps/behavior/pop-plugin-status</key>
<applyto>/apps/gramps/behavior/pop-plugin-status</applyto>
<owner>gramps</owner>
<type>bool</type>
<default>0</default>
<locale name="C">
<short>Automatically pop plugin status window</short>
<long>If set to 1, Plugin Status Window will pop automatically
when problems are detected on plugins load and reload.</long>
</locale>
</schema>
<schema> <schema>
<key>/schemas/apps/gramps/interface/view</key> <key>/schemas/apps/gramps/interface/view</key>
<applyto>/apps/gramps/interface/view</applyto> <applyto>/apps/gramps/interface/view</applyto>

View File

@ -2,7 +2,6 @@
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface> <glade-interface>
<requires lib="gnome"/>
<widget class="GtkDialog" id="plugstat"> <widget class="GtkDialog" id="plugstat">
<property name="visible">True</property> <property name="visible">True</property>
@ -19,6 +18,7 @@
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="has_separator">False</property> <property name="has_separator">False</property>
<signal name="delete_event" handler="on_plugstat_delete_event" last_modification_time="Sat, 20 Nov 2004 04:07:44 GMT"/>
<child internal-child="vbox"> <child internal-child="vbox">
<widget class="GtkVBox" id="vbox37"> <widget class="GtkVBox" id="vbox37">
@ -36,14 +36,28 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label">gtk-cancel</property> <property name="label">gtk-close</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property> <property name="focus_on_click">True</property>
<property name="response_id">0</property> <property name="response_id">-7</property>
<signal name="clicked" handler="on_close_clicked" last_modification_time="Thu, 12 Sep 2002 03:21:32 GMT"/> <signal name="clicked" handler="on_close_clicked" last_modification_time="Thu, 12 Sep 2002 03:21:32 GMT"/>
</widget> </widget>
</child> </child>
<child>
<widget class="GtkButton" id="button109">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-help</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-11</property>
<signal name="clicked" handler="on_help_clicked" last_modification_time="Sat, 20 Nov 2004 03:29:14 GMT"/>
</widget>
</child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
@ -90,6 +104,25 @@
<property name="fill">True</property> <property name="fill">True</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkCheckButton" id="pop_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Automatically pop out when problems are detected</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">6</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget> </widget>
</child> </child>
</widget> </widget>

View File

@ -57,7 +57,7 @@ import gtk
_person_handle = "" _person_handle = ""
_filter_num = 0 _filter_num = 0
_use_srcs = 0 _use_srcs = 0
_options = ( _person_id, _filter_num, _use_srcs ) _options = ( _person_handle, _filter_num, _use_srcs )
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #

View File

@ -1,4 +1,8 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003 Jesper Zedlitz # Copyright (C) 2003 Jesper Zedlitz
# Copyright (C) 2003-2004 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -15,6 +19,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# $Id$
"Export/Partition" "Export/Partition"
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -50,7 +56,7 @@ import WriteXML
personSeen = [] personSeen = []
familySeen = [] familySeen = []
database_for_unlinked_persons = RelLib.GrampsDB() #database_for_unlinked_persons = RelLib.GrampsDB()
prefix = "/tmp/test" prefix = "/tmp/test"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -63,8 +69,8 @@ def work_on_person( db, person ):
if (len(person.get_family_handle_list()) + len(person.get_parent_family_handle_list())) > 0: if (len(person.get_family_handle_list()) + len(person.get_parent_family_handle_list())) > 0:
database = db database = db
else: #else:
database = database_for_unlinked_persons # database = database_for_unlinked_persons
if( database.get_person_handle_map().has_key( person.get_handle() ) ): if( database.get_person_handle_map().has_key( person.get_handle() ) ):
return return