issue126-backup (#198)
All checks were successful
Build AppImage / Explore-Gitea-Actions (push) Successful in 1m33s
All checks were successful
Build AppImage / Explore-Gitea-Actions (push) Successful in 1m33s
reworked autosave, closes #126; update with restart
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
import sys
|
||||
import pathlib
|
||||
import os
|
||||
sys.path.append(str(pathlib.Path(__file__).absolute().parent.parent / 'src'))
|
||||
|
||||
from nmreval.configs import check_for_config
|
||||
@ -16,12 +17,45 @@ from nmreval.lib.logger import handle_exception
|
||||
sys.excepthook = handle_exception
|
||||
|
||||
from gui_qt import App
|
||||
from gui_qt.Qt import QtCore
|
||||
|
||||
app = App(['Team Rocket FTW!'])
|
||||
app = App(['NMReval'])
|
||||
|
||||
from gui_qt.main.mainwindow import NMRMainWindow
|
||||
from gui_qt.lib.backup import BackupManager
|
||||
|
||||
|
||||
def do_autosave():
|
||||
# autosave and update timestamp in db
|
||||
success = mplQt.autosave()
|
||||
if success:
|
||||
backuping.update_last_save()
|
||||
|
||||
# autosave stuff: keep track of instance and their backup files
|
||||
backuping = BackupManager()
|
||||
|
||||
# look for autosaves in DB without running programs
|
||||
files = backuping.search_unsaved()
|
||||
|
||||
# tell everyone what autosave files belongs to this process
|
||||
pid = os.getpid()
|
||||
bck_name = backuping.create_entry(pid)
|
||||
mplQt = NMRMainWindow(bck_file=bck_name)
|
||||
|
||||
# one manual autosave to create the file
|
||||
do_autosave()
|
||||
|
||||
# load all selected autosaves to program
|
||||
for f in files:
|
||||
mplQt.management.load_files(f)
|
||||
f.unlink()
|
||||
|
||||
timer = QtCore.QTimer()
|
||||
timer.timeout.connect(do_autosave)
|
||||
timer.start(3 * 60 * 1000)
|
||||
|
||||
app.aboutToQuit.connect(backuping.close)
|
||||
|
||||
mplQt = NMRMainWindow()
|
||||
mplQt.show()
|
||||
|
||||
sys.exit(app.exec())
|
||||
|
Reference in New Issue
Block a user