DB-API: Show last backup time/date, and total backup counts

This commit is contained in:
Doug Blank 2016-04-23 15:54:42 -04:00
parent e4afbc98cd
commit a925aa5cc8

View File

@ -35,6 +35,7 @@ import bisect
import ast import ast
import sys import sys
import datetime import datetime
import glob
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -1992,6 +1993,17 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
_("Version") _("Version")
_("Data version") _("Data version")
""" """
last_backup = "n/a"
backups = sorted(glob.glob(os.path.join(
self._directory, "backup-*.gramps")), reverse=True)
if backups:
path, filename = os.path.split(backups[0])
filename, ext = os.path.splitext(filename)
if filename.count("-") == 6:
backup, year, month, day, hour, minute, second = filename.split("-")
last_backup = time.strftime('%x %X', time.localtime(time.mktime(
(int(year), int(month), int(day), int(hour), int(minute), int(second),
0, 0, 0))))
return { return {
_("Number of people"): self.get_number_of_people(), _("Number of people"): self.get_number_of_people(),
_("Number of families"): self.get_number_of_families(), _("Number of families"): self.get_number_of_families(),
@ -2004,6 +2016,8 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
_("Number of notes"): self.get_number_of_notes(), _("Number of notes"): self.get_number_of_notes(),
_("Number of tags"): self.get_number_of_tags(), _("Number of tags"): self.get_number_of_tags(),
_("Data version"): ".".join([str(v) for v in self.VERSION]), _("Data version"): ".".join([str(v) for v in self.VERSION]),
_("Backups, count"): str(len(backups)),
_("Backups, last"): last_backup,
} }
def get_dbname(self): def get_dbname(self):