diff --git a/src/libprs500/gui2/main.py b/src/libprs500/gui2/main.py index 188ad0a3f7..c49c6acb0f 100644 --- a/src/libprs500/gui2/main.py +++ b/src/libprs500/gui2/main.py @@ -801,9 +801,9 @@ def main(args=sys.argv): initialize_file_icon_provider() try: main = Main() - except DatabaseLocked: + except DatabaseLocked, err: QMessageBox.critical(None, 'Cannot Start '+__appname__, - 'Another program is using the database. Perhaps %s is already running?'%(__appname__,)) + '
Another program is using the database.
Perhaps %s is already running?
If not try deleting the file %s'%(__appname__, err.lock_file_path))
return 1
sys.excepthook = main.unhandled_exception
return app.exec_()
diff --git a/src/libprs500/library/database.py b/src/libprs500/library/database.py
index a44f68cac1..3735dae0bf 100644
--- a/src/libprs500/library/database.py
+++ b/src/libprs500/library/database.py
@@ -42,33 +42,38 @@ class Concatenate(object):
_lock_file = None
class DatabaseLocked(Exception):
- pass
+
+ def __init__(self, msg, lock_file_path):
+ Exception.__init__(self, msg)
+ self.lock_file_path = lock_file_path
def _lock(path):
path = os.path.join(os.path.dirname(path), '.'+os.path.basename(path)+'.lock')
global _lock_file
if _lock_file is not None:
- raise DatabaseLocked('Database already locked in this instance.')
+ raise DatabaseLocked('Database already locked in this instance.', _lock_file.name)
try:
_lock_file = open(path, 'wb')
except IOError:
- raise DatabaseLocked('Database in use by another instance')
+ raise DatabaseLocked('Database in use by another instance', _lock_file.name)
try:
import fcntl, errno
try:
fcntl.lockf(_lock_file.fileno(), fcntl.LOCK_EX|fcntl.LOCK_NB)
except IOError, err:
+ path = _lock_file.name
_lock_file = None
if err.errno in (errno.EACCES, errno.EAGAIN):
- raise DatabaseLocked('Database in use by another instance')
+ raise DatabaseLocked('Database in use by another instance', path)
except ImportError:
try:
import msvcrt
try:
msvcrt.locking(_lock_file.fileno(), msvcrt.LK_NBLCK, 1)
except IOError:
+ path = _lock_file.name
_lock_file = None
- raise DatabaseLocked('Database in use by another instance')
+ raise DatabaseLocked('Database in use by another instance', path)
except ImportError:
pass