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:
@@ -420,7 +420,7 @@ def run():
|
|||||||
LOG.debug('environment: LANGUAGE is not defined')
|
LOG.debug('environment: LANGUAGE is not defined')
|
||||||
|
|
||||||
if argpars.need_gui():
|
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:
|
if "--qml" in sys.argv:
|
||||||
from .guiQML.grampsqml import startqml
|
from .guiQML.grampsqml import startqml
|
||||||
startqml(error, argpars)
|
startqml(error, argpars)
|
||||||
|
@@ -29,11 +29,14 @@ __date__ ="$Apr 20, 2010 3:13:24 PM$"
|
|||||||
|
|
||||||
from . import tool
|
from . import tool
|
||||||
|
|
||||||
from ._guioptions import make_gui_option, add_gui_options
|
try:
|
||||||
from gramps.gen.plug import MenuOptions
|
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 gramps.gen.plug import MenuOptions
|
||||||
from . import _windows as PluginWindows
|
|
||||||
|
|
||||||
# This needs to go above Tool and MenuOption as it needs both
|
# This needs to go above Tool and MenuOption as it needs both
|
||||||
class MenuToolOptions(MenuOptions, tool.ToolOptions):
|
class MenuToolOptions(MenuOptions, tool.ToolOptions):
|
||||||
|
@@ -1038,7 +1038,7 @@ class ToolManagedWindowBatch(tool.BatchTool, ToolManagedWindowBase):
|
|||||||
# This constructor will ask a question, set self.fail:
|
# This constructor will ask a question, set self.fail:
|
||||||
self.dbstate = dbstate
|
self.dbstate = dbstate
|
||||||
self.uistate = uistate
|
self.uistate = uistate
|
||||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||||
if not self.fail:
|
if not self.fail:
|
||||||
ToolManagedWindowBase.__init__(self, dbstate, uistate,
|
ToolManagedWindowBase.__init__(self, dbstate, uistate,
|
||||||
options_class, name, callback)
|
options_class, name, callback)
|
||||||
|
@@ -101,11 +101,12 @@ class Tool(object):
|
|||||||
class BatchTool(Tool):
|
class BatchTool(Tool):
|
||||||
"""
|
"""
|
||||||
Same as Tool, except the warning is displayed about the potential
|
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):
|
def __init__(self, dbstate, uistate, options_class, name):
|
||||||
|
if uistate:
|
||||||
# TODO: should we replace this with a callback?
|
# TODO: should we replace this with a callback?
|
||||||
from ..dialog import QuestionDialog2
|
from ..dialog import QuestionDialog2
|
||||||
warn_dialog = QuestionDialog2(
|
warn_dialog = QuestionDialog2(
|
||||||
|
@@ -79,7 +79,7 @@ class ChangeNames(tool.BatchTool, ManagedWindow):
|
|||||||
ManagedWindow.__init__(self,uistate,[],self.__class__)
|
ManagedWindow.__init__(self,uistate,[],self.__class__)
|
||||||
self.set_window(Gtk.Window(),Gtk.Label(),'')
|
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:
|
if self.fail:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@@ -56,7 +56,7 @@ class ChangeTypes(tool.BatchTool, ManagedWindow):
|
|||||||
|
|
||||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
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:
|
if self.fail:
|
||||||
return
|
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.unknown import make_unknown
|
||||||
from gramps.gen.utils.file import (media_path_full, find_file, fix_encoding,
|
from gramps.gen.utils.file import (media_path_full, find_file, fix_encoding,
|
||||||
get_unicode_path_from_file_chooser)
|
get_unicode_path_from_file_chooser)
|
||||||
from gramps.gui.utils import ProgressMeter
|
|
||||||
from gramps.gui.managedwindow import ManagedWindow
|
from gramps.gui.managedwindow import ManagedWindow
|
||||||
|
|
||||||
from gramps.gui.plug import tool
|
from gramps.gui.plug import tool
|
||||||
@@ -86,6 +85,12 @@ ngettext = glocale.translation.ngettext
|
|||||||
# All except 09, 0A, 0D are replaced with space.
|
# All except 09, 0A, 0D are replaced with space.
|
||||||
strip_dict = dict.fromkeys(list(range(9))+list(range(11,13))+list(range(14, 32)), " ")
|
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
|
# Low Level repair
|
||||||
@@ -132,11 +137,15 @@ def cross_table_duplicates(db):
|
|||||||
class Check(tool.BatchTool):
|
class Check(tool.BatchTool):
|
||||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
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:
|
if self.fail:
|
||||||
return
|
return
|
||||||
|
|
||||||
cli = uistate is None
|
cli = uistate is None
|
||||||
|
if uistate:
|
||||||
|
from gramps.gui.utils import ProgressMeter as PM
|
||||||
|
global ProgressMeter
|
||||||
|
ProgressMeter = PM
|
||||||
|
|
||||||
if self.db.readonly:
|
if self.db.readonly:
|
||||||
# TODO: split plugin in a check and repair part to support
|
# TODO: split plugin in a check and repair part to support
|
||||||
@@ -2242,6 +2251,7 @@ class Report(ManagedWindow):
|
|||||||
if cl:
|
if cl:
|
||||||
print (text)
|
print (text)
|
||||||
|
|
||||||
|
if uistate:
|
||||||
ManagedWindow.__init__(self, uistate, [], self)
|
ManagedWindow.__init__(self, uistate, [], self)
|
||||||
|
|
||||||
topDialog = Glade()
|
topDialog = Glade()
|
||||||
|
@@ -69,7 +69,7 @@ class EventNames(tool.BatchTool, ManagedWindow):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
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:
|
if not self.fail:
|
||||||
uistate.set_busy_cursor(True)
|
uistate.set_busy_cursor(True)
|
||||||
|
@@ -419,7 +419,7 @@ class ExtractCity(tool.BatchTool, ManagedWindow):
|
|||||||
ManagedWindow.__init__(self, uistate, [], self.__class__)
|
ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||||
self.set_window(Gtk.Window(), Gtk.Label(), '')
|
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:
|
if not self.fail:
|
||||||
uistate.set_busy_cursor(True)
|
uistate.set_busy_cursor(True)
|
||||||
|
@@ -97,7 +97,7 @@ class MergeCitations(tool.BatchTool,ManagedWindow):
|
|||||||
self.dbstate = dbstate
|
self.dbstate = dbstate
|
||||||
self.set_window(Gtk.Window(), Gtk.Label(), '')
|
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:
|
if not self.fail:
|
||||||
uistate.set_busy_cursor(True)
|
uistate.set_busy_cursor(True)
|
||||||
|
@@ -108,7 +108,7 @@ class PatchNames(tool.BatchTool, ManagedWindow):
|
|||||||
ManagedWindow.__init__(self, uistate, [], self.__class__)
|
ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||||
self.set_window(Gtk.Window(), Gtk.Label(), '')
|
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:
|
if self.fail:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@@ -60,7 +60,7 @@ _parseformat = re.compile('.*%(\d+)[^\d]+')
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class ReorderIds(tool.BatchTool):
|
class ReorderIds(tool.BatchTool):
|
||||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
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:
|
if self.fail:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@@ -121,7 +121,7 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
if dbstate.db.readonly:
|
if dbstate.db.readonly:
|
||||||
return
|
return
|
||||||
|
|
||||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||||
|
|
||||||
if self.fail:
|
if self.fail:
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user