Continued work on GEP008: Move GrampsDbUtils/_Backup.py to gen/db/backup.py.
svn: r13856
This commit is contained in:
parent
f90175e10c
commit
806bd63ca2
@ -71,6 +71,7 @@ src/gen/proxy/filter.py
|
|||||||
src/gen/proxy/__init__.py
|
src/gen/proxy/__init__.py
|
||||||
|
|
||||||
# gen db API
|
# gen db API
|
||||||
|
src/gen/db/backup.py
|
||||||
src/gen/db/base.py
|
src/gen/db/base.py
|
||||||
src/gen/db/dbdir.py
|
src/gen/db/dbdir.py
|
||||||
src/gen/db/cursor.py
|
src/gen/db/cursor.py
|
||||||
@ -345,7 +346,6 @@ src/docgen/SpreadSheetDoc.py
|
|||||||
src/docgen/TextBufDoc.py
|
src/docgen/TextBufDoc.py
|
||||||
|
|
||||||
# GrampsDbUtils package
|
# GrampsDbUtils package
|
||||||
src/GrampsDbUtils/_Backup.py
|
|
||||||
src/GrampsDbUtils/_GedcomInfo.py
|
src/GrampsDbUtils/_GedcomInfo.py
|
||||||
src/GrampsDbUtils/_GedcomStageOne.py
|
src/GrampsDbUtils/_GedcomStageOne.py
|
||||||
#src/GrampsDbUtils/_GedcomLex.py
|
#src/GrampsDbUtils/_GedcomLex.py
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
pkgdatadir = $(datadir)/@PACKAGE@/GrampsDbUtils
|
pkgdatadir = $(datadir)/@PACKAGE@/GrampsDbUtils
|
||||||
|
|
||||||
pkgdata_PYTHON = \
|
pkgdata_PYTHON = \
|
||||||
_Backup.py\
|
|
||||||
_GedcomChar.py\
|
_GedcomChar.py\
|
||||||
_GedcomInfo.py\
|
_GedcomInfo.py\
|
||||||
_GedcomLex.py\
|
_GedcomLex.py\
|
||||||
|
@ -29,5 +29,3 @@ from _GedcomInfo import (personalConstantEvents, familyConstantEvents,
|
|||||||
|
|
||||||
from _GedcomParse import GedcomParser
|
from _GedcomParse import GedcomParser
|
||||||
|
|
||||||
import _Backup as Backup
|
|
||||||
|
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
pkgdatadir = $(datadir)/@PACKAGE@/gen/db
|
pkgdatadir = $(datadir)/@PACKAGE@/gen/db
|
||||||
|
|
||||||
pkgdata_PYTHON = \
|
pkgdata_PYTHON = \
|
||||||
__init__.py\
|
__init__.py \
|
||||||
|
backup.py \
|
||||||
base.py \
|
base.py \
|
||||||
bsddbtxn.py \
|
bsddbtxn.py \
|
||||||
cursor.py \
|
cursor.py \
|
||||||
|
@ -27,3 +27,4 @@ from txn import *
|
|||||||
from undoredo import *
|
from undoredo import *
|
||||||
from exceptions import *
|
from exceptions import *
|
||||||
from write import *
|
from write import *
|
||||||
|
from backup import backup, restore
|
||||||
|
@ -50,14 +50,15 @@ db.
|
|||||||
# load standard python libraries
|
# load standard python libraries
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gettext import gettext as _
|
import os
|
||||||
|
import cPickle as pickle
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Gramps libs
|
# Gramps libs
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
from QuestionDialog import ErrorDialog
|
from gen.db.exceptions import GrampsDbException
|
||||||
from gen.db.write import FAMILY_TBL, PLACES_TBL, SOURCES_TBL, MEDIA_TBL, \
|
from gen.db.write import FAMILY_TBL, PLACES_TBL, SOURCES_TBL, MEDIA_TBL, \
|
||||||
EVENTS_TBL, PERSON_TBL, REPO_TBL, NOTE_TBL, META
|
EVENTS_TBL, PERSON_TBL, REPO_TBL, NOTE_TBL, META
|
||||||
|
|
||||||
@ -67,9 +68,6 @@ from gen.db.write import FAMILY_TBL, PLACES_TBL, SOURCES_TBL, MEDIA_TBL, \
|
|||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
import cPickle as pickle
|
|
||||||
|
|
||||||
LOG = logging.getLogger(".Backup")
|
LOG = logging.getLogger(".Backup")
|
||||||
|
|
||||||
def backup(database):
|
def backup(database):
|
||||||
@ -86,7 +84,7 @@ def backup(database):
|
|||||||
try:
|
try:
|
||||||
__do_export(database)
|
__do_export(database)
|
||||||
except (OSError, IOError), msg:
|
except (OSError, IOError), msg:
|
||||||
ErrorDialog(_("Error saving backup data"), str(msg))
|
raise GrampsDbException(str(msg))
|
||||||
|
|
||||||
def __mk_backup_name(database, base):
|
def __mk_backup_name(database, base):
|
||||||
"""
|
"""
|
||||||
@ -154,7 +152,7 @@ def restore(database):
|
|||||||
try:
|
try:
|
||||||
__do_restore(database)
|
__do_restore(database)
|
||||||
except (OSError, IOError), msg:
|
except (OSError, IOError), msg:
|
||||||
ErrorDialog(_("Error restoring backup data"), str(msg))
|
raise GrampsDbException(str(msg))
|
||||||
|
|
||||||
def __do_restore(database):
|
def __do_restore(database):
|
||||||
"""
|
"""
|
@ -71,10 +71,11 @@ from QuestionDialog import ErrorDialog, QuestionDialog
|
|||||||
from gen.db import GrampsDBDir
|
from gen.db import GrampsDBDir
|
||||||
from gui.pluginmanager import GuiPluginManager
|
from gui.pluginmanager import GuiPluginManager
|
||||||
from cli.clidbman import CLIDbManager, NAME_FILE, time_val
|
from cli.clidbman import CLIDbManager, NAME_FILE, time_val
|
||||||
import GrampsDbUtils
|
|
||||||
from DdTargets import DdTargets
|
from DdTargets import DdTargets
|
||||||
import RecentFiles
|
import RecentFiles
|
||||||
from glade import Glade
|
from glade import Glade
|
||||||
|
from gen.db.backup import restore
|
||||||
|
from gen.db.exceptions import GrampsDbException
|
||||||
|
|
||||||
_RETURN = gtk.gdk.keyval_from_name("Return")
|
_RETURN = gtk.gdk.keyval_from_name("Return")
|
||||||
_KP_ENTER = gtk.gdk.keyval_from_name("KP_Enter")
|
_KP_ENTER = gtk.gdk.keyval_from_name("KP_Enter")
|
||||||
@ -641,7 +642,12 @@ class DbManager(CLIDbManager):
|
|||||||
dbase.load(dirname, None)
|
dbase.load(dirname, None)
|
||||||
|
|
||||||
self.__start_cursor(_("Rebuilding database from backup files"))
|
self.__start_cursor(_("Rebuilding database from backup files"))
|
||||||
GrampsDbUtils.Backup.restore(dbase)
|
|
||||||
|
try:
|
||||||
|
restore(dbase)
|
||||||
|
except GrampsDbException, msg:
|
||||||
|
ErrorDialog(_("Error restoring backup data"), msg)
|
||||||
|
|
||||||
self.__end_cursor()
|
self.__end_cursor()
|
||||||
|
|
||||||
dbase.close()
|
dbase.close()
|
||||||
|
@ -72,13 +72,14 @@ from QuestionDialog import (ErrorDialog, WarningDialog, QuestionDialog2,
|
|||||||
InfoDialog)
|
InfoDialog)
|
||||||
import gui.views.pageview as PageView
|
import gui.views.pageview as PageView
|
||||||
import Navigation
|
import Navigation
|
||||||
import RecentFiles
|
|
||||||
from BasicUtils import name_displayer
|
from BasicUtils import name_displayer
|
||||||
from gui import widgets
|
from gui import widgets
|
||||||
import UndoHistory
|
import UndoHistory
|
||||||
from gui.dbloader import DbLoader
|
from gui.dbloader import DbLoader
|
||||||
import GrampsDisplay
|
import GrampsDisplay
|
||||||
from gen.utils import ProgressMonitor
|
from gen.utils import ProgressMonitor
|
||||||
|
from gen.db.backup import backup
|
||||||
|
from gen.db.exceptions import GrampsDbException
|
||||||
from GrampsAboutDialog import GrampsAboutDialog
|
from GrampsAboutDialog import GrampsAboutDialog
|
||||||
import ProgressDialog
|
import ProgressDialog
|
||||||
|
|
||||||
@ -693,13 +694,14 @@ class ViewManager(CLIManager):
|
|||||||
"""
|
"""
|
||||||
Backup the current file as a backup file.
|
Backup the current file as a backup file.
|
||||||
"""
|
"""
|
||||||
import GrampsDbUtils
|
|
||||||
|
|
||||||
if self.dbstate.db.has_changed:
|
if self.dbstate.db.has_changed:
|
||||||
self.uistate.set_busy_cursor(1)
|
self.uistate.set_busy_cursor(1)
|
||||||
self.uistate.progress.show()
|
self.uistate.progress.show()
|
||||||
self.uistate.push_message(self.dbstate, _("Autobackup..."))
|
self.uistate.push_message(self.dbstate, _("Autobackup..."))
|
||||||
GrampsDbUtils.Backup.backup(self.dbstate.db)
|
try:
|
||||||
|
backup(self.dbstate.db)
|
||||||
|
except GrampsDbException, msg:
|
||||||
|
ErrorDialog(_("Error saving backup data"), msg)
|
||||||
self.uistate.set_busy_cursor(0)
|
self.uistate.set_busy_cursor(0)
|
||||||
self.uistate.progress.hide()
|
self.uistate.progress.hide()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user