2007-06-18 Don Allingham <don@gramps-project.org>
* src/GrampsDb/_GrampsDBDir.py: support lock file * src/DbManager.py: display locked file message svn: r8584
This commit is contained in:
parent
cf52ebb90d
commit
b5ce4a2c59
@ -1,3 +1,7 @@
|
|||||||
|
2007-06-18 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/GrampsDb/_GrampsDBDir.py: support lock file
|
||||||
|
* src/DbManager.py: display locked file message
|
||||||
|
|
||||||
2007-06-18 Alex Roitman <shura@gramps-project.org>
|
2007-06-18 Alex Roitman <shura@gramps-project.org>
|
||||||
* src/DateEdit.py (DateEditorDialog.switch_calendar): Only convert
|
* src/DateEdit.py (DateEditorDialog.switch_calendar): Only convert
|
||||||
non-empty dates to new calendar.
|
non-empty dates to new calendar.
|
||||||
|
@ -44,6 +44,11 @@ from gettext import gettext as _
|
|||||||
import logging
|
import logging
|
||||||
LOG = logging.getLogger(".DbManager")
|
LOG = logging.getLogger(".DbManager")
|
||||||
|
|
||||||
|
if os.sys.platform == "win32":
|
||||||
|
_rcs_found = os.system("rcs -V >nul 2>nul") == 0
|
||||||
|
else:
|
||||||
|
_rcs_found = os.system("rcs -V >/dev/null 2>/dev/null") == 0
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# GTK/Gnome modules
|
# GTK/Gnome modules
|
||||||
@ -249,6 +254,15 @@ class DbManager:
|
|||||||
(enable, stock_id) = icon_values(dirpath, self.active,
|
(enable, stock_id) = icon_values(dirpath, self.active,
|
||||||
self.dbstate.db.is_open())
|
self.dbstate.db.is_open())
|
||||||
|
|
||||||
|
if (stock_id == 'gramps-lock'):
|
||||||
|
try:
|
||||||
|
fname = os.path.join(dirpath, "lock")
|
||||||
|
f = open(fname)
|
||||||
|
last = f.read().strip()
|
||||||
|
f.close()
|
||||||
|
except:
|
||||||
|
last = _("Unknown")
|
||||||
|
|
||||||
self.current_names.append(
|
self.current_names.append(
|
||||||
(name, os.path.join(dbdir, dpath), path_name,
|
(name, os.path.join(dbdir, dpath), path_name,
|
||||||
last, tval, enable, stock_id))
|
last, tval, enable, stock_id))
|
||||||
@ -466,6 +480,8 @@ def icon_values(dirpath, active, open):
|
|||||||
return (True, gtk.STOCK_DIALOG_ERROR)
|
return (True, gtk.STOCK_DIALOG_ERROR)
|
||||||
elif dirpath == active and open:
|
elif dirpath == active and open:
|
||||||
return (True, gtk.STOCK_OPEN)
|
return (True, gtk.STOCK_OPEN)
|
||||||
|
elif os.path.isfile(os.path.join(dirpath,"lock")):
|
||||||
|
return (True, 'gramps-lock')
|
||||||
else:
|
else:
|
||||||
return (False, "")
|
return (False, "")
|
||||||
|
|
||||||
|
@ -208,6 +208,10 @@ class GrampsDBDir(GrampsDbBase,UpdateCallback):
|
|||||||
mypath = os.path.join(self.get_save_path(),"need_recover")
|
mypath = os.path.join(self.get_save_path(),"need_recover")
|
||||||
ofile = open(mypath, "w")
|
ofile = open(mypath, "w")
|
||||||
ofile.close()
|
ofile.close()
|
||||||
|
try:
|
||||||
|
clear_lock_file(self.get_save_path())
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def __get_cursor(self, table):
|
def __get_cursor(self, table):
|
||||||
try:
|
try:
|
||||||
@ -435,9 +439,9 @@ class GrampsDBDir(GrampsDbBase,UpdateCallback):
|
|||||||
try:
|
try:
|
||||||
if self.__check_readonly(name):
|
if self.__check_readonly(name):
|
||||||
mode = "r"
|
mode = "r"
|
||||||
|
write_lock_file(name)
|
||||||
return self.__load(name, callback, mode)
|
return self.__load(name, callback, mode)
|
||||||
except DBERRS, msg:
|
except DBERRS, msg:
|
||||||
print name
|
|
||||||
self.__log_error()
|
self.__log_error()
|
||||||
raise Errors.DbError(msg)
|
raise Errors.DbError(msg)
|
||||||
|
|
||||||
@ -1211,9 +1215,12 @@ class GrampsDBDir(GrampsDbBase,UpdateCallback):
|
|||||||
def close(self):
|
def close(self):
|
||||||
try:
|
try:
|
||||||
self.__close()
|
self.__close()
|
||||||
|
clear_lock_file(self.get_save_path())
|
||||||
except DBERRS, msg:
|
except DBERRS, msg:
|
||||||
self.__log_error()
|
self.__log_error()
|
||||||
raise Errors.DbError(msg)
|
raise Errors.DbError(msg)
|
||||||
|
except IOError:
|
||||||
|
pass
|
||||||
|
|
||||||
def __close(self):
|
def __close(self):
|
||||||
if not self.db_is_open:
|
if not self.db_is_open:
|
||||||
@ -1721,6 +1728,20 @@ class BdbTransaction(Transaction):
|
|||||||
def _mkname(path, name):
|
def _mkname(path, name):
|
||||||
return os.path.join(path, name + ".db")
|
return os.path.join(path, name + ".db")
|
||||||
|
|
||||||
|
def clear_lock_file(name):
|
||||||
|
os.unlink(os.path.join(name, "lock"))
|
||||||
|
|
||||||
|
def write_lock_file(name):
|
||||||
|
f = open(os.path.join(name, "lock"), "w")
|
||||||
|
if os.name == 'nt':
|
||||||
|
text = os.environ['USERNAME']
|
||||||
|
else:
|
||||||
|
import pwd
|
||||||
|
host = os.uname()[1]
|
||||||
|
user = os.getlogin()
|
||||||
|
text = "%s@%s" % (user, host)
|
||||||
|
f.write(_("Locked by %s") % text)
|
||||||
|
f.close()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user