6953: remove "undo history warning" under CLI
Merged from gramps40 the commits below and verified there are no more instances of BatchTool on trunk to change as well. commit 657a57fb7de3c9804dfbff5b27f824ff79ead2ae Author: Vassilii Khachaturov <vassilii@tarunz.org> Date: Wed Aug 21 17:24:41 2013 +0000 6953: remove "undo history warning" under CLI Port my fix from gramps34. In addition, the Check tool now has a hardwired dependency on ProgressMeter. Make a nullifying mock locally and only set it to the real thing only under GUI. Tested with impex.sh (further stages after check still fail, see bug #6878). git-svn-id: svn+ssh://svn.code.sf.net/p/gramps/code/branches/maintenance/gramps40@22899 4ae1f11a-8b86-4847-b8af-ab372f36d1fd commit 064d9a7b36770857f7fd68b35ade6e8f3f52b81a Author: Vassilii Khachaturov <vassilii@tarunz.org> Date: Wed Aug 21 17:24:18 2013 +0000 action 'tool' CLI handler broken w/o DISPLAY Preparing to port my fix for 6953: remove "undo history warning" when the BatchTool run from cli (e.g., "check") from gramps34, the ground state was worse in gramps40... git-svn-id: svn+ssh://svn.code.sf.net/p/gramps/code/branches/maintenance/gramps40@22898 4ae1f11a-8b86-4847-b8af-ab372f36d1fd svn: r22902
This commit is contained in:
parent
7c5d15b678
commit
b142062187
@ -420,7 +420,7 @@ def run():
|
||||
LOG.debug('environment: LANGUAGE is not defined')
|
||||
|
||||
if argpars.need_gui():
|
||||
#A GUI is needed, set it up
|
||||
LOG.debug("A GUI is needed, set it up")
|
||||
if "--qml" in sys.argv:
|
||||
from .guiQML.grampsqml import startqml
|
||||
startqml(error, argpars)
|
||||
|
@ -29,11 +29,14 @@ __date__ ="$Apr 20, 2010 3:13:24 PM$"
|
||||
|
||||
from . import tool
|
||||
|
||||
from ._guioptions import make_gui_option, add_gui_options
|
||||
from gramps.gen.plug import MenuOptions
|
||||
try:
|
||||
from ._guioptions import make_gui_option, add_gui_options
|
||||
from ._dialogs import ReportPluginDialog, ToolPluginDialog
|
||||
from . import _windows as PluginWindows
|
||||
except TypeError: # No GUI
|
||||
pass
|
||||
|
||||
from ._dialogs import ReportPluginDialog, ToolPluginDialog
|
||||
from . import _windows as PluginWindows
|
||||
from gramps.gen.plug import MenuOptions
|
||||
|
||||
# This needs to go above Tool and MenuOption as it needs both
|
||||
class MenuToolOptions(MenuOptions, tool.ToolOptions):
|
||||
|
@ -1038,7 +1038,7 @@ class ToolManagedWindowBatch(tool.BatchTool, ToolManagedWindowBase):
|
||||
# This constructor will ask a question, set self.fail:
|
||||
self.dbstate = dbstate
|
||||
self.uistate = uistate
|
||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||
if not self.fail:
|
||||
ToolManagedWindowBase.__init__(self, dbstate, uistate,
|
||||
options_class, name, callback)
|
||||
|
@ -101,25 +101,26 @@ class Tool(object):
|
||||
class BatchTool(Tool):
|
||||
"""
|
||||
Same as Tool, except the warning is displayed about the potential
|
||||
loss of undo history. Should be used for tools using batch transactions.
|
||||
|
||||
loss of undo history when GUI is available.
|
||||
Should be used for tools using batch transactions.
|
||||
"""
|
||||
|
||||
def __init__(self, dbstate, options_class, name):
|
||||
# TODO: should we replace this with a callback?
|
||||
from ..dialog import QuestionDialog2
|
||||
warn_dialog = QuestionDialog2(
|
||||
_('Undo history warning'),
|
||||
_('Proceeding with this tool will erase the undo history '
|
||||
'for this session. In particular, you will not be able '
|
||||
'to revert the changes made by this tool or any changes '
|
||||
'made prior to it.\n\n'
|
||||
'If you think you may want to revert running this tool, '
|
||||
'please stop here and backup your database.'),
|
||||
_('_Proceed with the tool'), _('_Stop'))
|
||||
if not warn_dialog.run():
|
||||
self.fail = True
|
||||
return
|
||||
def __init__(self, dbstate, uistate, options_class, name):
|
||||
if uistate:
|
||||
# TODO: should we replace this with a callback?
|
||||
from ..dialog import QuestionDialog2
|
||||
warn_dialog = QuestionDialog2(
|
||||
_('Undo history warning'),
|
||||
_('Proceeding with this tool will erase the undo history '
|
||||
'for this session. In particular, you will not be able '
|
||||
'to revert the changes made by this tool or any changes '
|
||||
'made prior to it.\n\n'
|
||||
'If you think you may want to revert running this tool, '
|
||||
'please stop here and backup your database.'),
|
||||
_('_Proceed with the tool'), _('_Stop'))
|
||||
if not warn_dialog.run():
|
||||
self.fail = True
|
||||
return
|
||||
|
||||
Tool.__init__(self, dbstate, options_class, name)
|
||||
self.fail = False
|
||||
|
@ -79,7 +79,7 @@ class ChangeNames(tool.BatchTool, ManagedWindow):
|
||||
ManagedWindow.__init__(self,uistate,[],self.__class__)
|
||||
self.set_window(Gtk.Window(),Gtk.Label(),'')
|
||||
|
||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||
if self.fail:
|
||||
return
|
||||
|
||||
|
@ -56,7 +56,7 @@ class ChangeTypes(tool.BatchTool, ManagedWindow):
|
||||
|
||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||
|
||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||
if self.fail:
|
||||
return
|
||||
|
||||
|
@ -70,7 +70,6 @@ from gramps.gen.utils.db import family_name
|
||||
from gramps.gen.utils.unknown import make_unknown
|
||||
from gramps.gen.utils.file import (media_path_full, find_file, fix_encoding,
|
||||
get_unicode_path_from_file_chooser)
|
||||
from gramps.gui.utils import ProgressMeter
|
||||
from gramps.gui.managedwindow import ManagedWindow
|
||||
|
||||
from gramps.gui.plug import tool
|
||||
@ -86,6 +85,12 @@ ngettext = glocale.translation.ngettext
|
||||
# All except 09, 0A, 0D are replaced with space.
|
||||
strip_dict = dict.fromkeys(list(range(9))+list(range(11,13))+list(range(14, 32)), " ")
|
||||
|
||||
class ProgressMeter(object):
|
||||
def __init__(self, *args): pass
|
||||
def set_pass(self, *args): pass
|
||||
def step(self): pass
|
||||
def close(self): pass
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Low Level repair
|
||||
@ -132,11 +137,15 @@ def cross_table_duplicates(db):
|
||||
class Check(tool.BatchTool):
|
||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||
|
||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||
if self.fail:
|
||||
return
|
||||
|
||||
cli = uistate is None
|
||||
if uistate:
|
||||
from gramps.gui.utils import ProgressMeter as PM
|
||||
global ProgressMeter
|
||||
ProgressMeter = PM
|
||||
|
||||
if self.db.readonly:
|
||||
# TODO: split plugin in a check and repair part to support
|
||||
@ -2242,20 +2251,21 @@ class Report(ManagedWindow):
|
||||
if cl:
|
||||
print (text)
|
||||
|
||||
ManagedWindow.__init__(self, uistate, [], self)
|
||||
if uistate:
|
||||
ManagedWindow.__init__(self, uistate, [], self)
|
||||
|
||||
topDialog = Glade()
|
||||
topDialog.get_object("close").connect('clicked', self.close)
|
||||
window = topDialog.toplevel
|
||||
textwindow = topDialog.get_object("textwindow")
|
||||
textwindow.get_buffer().set_text(text)
|
||||
topDialog = Glade()
|
||||
topDialog.get_object("close").connect('clicked', self.close)
|
||||
window = topDialog.toplevel
|
||||
textwindow = topDialog.get_object("textwindow")
|
||||
textwindow.get_buffer().set_text(text)
|
||||
|
||||
self.set_window(window,
|
||||
#topDialog.get_widget("title"),
|
||||
topDialog.get_object("title"),
|
||||
_("Integrity Check Results"))
|
||||
self.set_window(window,
|
||||
#topDialog.get_widget("title"),
|
||||
topDialog.get_object("title"),
|
||||
_("Integrity Check Results"))
|
||||
|
||||
self.show()
|
||||
self.show()
|
||||
|
||||
def build_menu_names(self, obj):
|
||||
return (_('Check and Repair'), None)
|
||||
|
@ -69,7 +69,7 @@ class EventNames(tool.BatchTool, ManagedWindow):
|
||||
"""
|
||||
|
||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||
|
||||
if not self.fail:
|
||||
uistate.set_busy_cursor(True)
|
||||
|
@ -419,7 +419,7 @@ class ExtractCity(tool.BatchTool, ManagedWindow):
|
||||
ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||
self.set_window(Gtk.Window(), Gtk.Label(), '')
|
||||
|
||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||
|
||||
if not self.fail:
|
||||
uistate.set_busy_cursor(True)
|
||||
|
@ -97,7 +97,7 @@ class MergeCitations(tool.BatchTool,ManagedWindow):
|
||||
self.dbstate = dbstate
|
||||
self.set_window(Gtk.Window(), Gtk.Label(), '')
|
||||
|
||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||
|
||||
if not self.fail:
|
||||
uistate.set_busy_cursor(True)
|
||||
|
@ -108,7 +108,7 @@ class PatchNames(tool.BatchTool, ManagedWindow):
|
||||
ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||
self.set_window(Gtk.Window(), Gtk.Label(), '')
|
||||
|
||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||
if self.fail:
|
||||
return
|
||||
|
||||
|
@ -60,7 +60,7 @@ _parseformat = re.compile('.*%(\d+)[^\d]+')
|
||||
#-------------------------------------------------------------------------
|
||||
class ReorderIds(tool.BatchTool):
|
||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||
if self.fail:
|
||||
return
|
||||
|
||||
|
@ -121,7 +121,7 @@ class TestcaseGenerator(tool.BatchTool):
|
||||
if dbstate.db.readonly:
|
||||
return
|
||||
|
||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||
|
||||
if self.fail:
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user