issue126-backup #198
@ -17,31 +17,35 @@ from nmreval.lib.logger import handle_exception
|
||||
sys.excepthook = handle_exception
|
||||
|
||||
from gui_qt import App
|
||||
from gui_qt.Qt import QtCore, QtWidgets, QtGui
|
||||
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
|
||||
from gui_qt.lib.update import UpdateDialog
|
||||
|
||||
|
||||
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()
|
||||
@ -54,5 +58,4 @@ app.aboutToQuit.connect(backuping.close)
|
||||
|
||||
mplQt.show()
|
||||
|
||||
|
||||
sys.exit(app.exec())
|
||||
|
@ -6,7 +6,7 @@ from pathlib import Path
|
||||
from nmreval.configs import config_paths
|
||||
from ..Qt import QtCore, QtWidgets
|
||||
|
||||
DB_FILE = '/autohome/dominik/nmreval/nmreval.db'
|
||||
DB_FILE = '/tmp/nmreval.db'
|
||||
|
||||
|
||||
class BackupManager(QtCore.QObject):
|
||||
@ -119,7 +119,6 @@ class BackupManager(QtCore.QObject):
|
||||
Path(DB_FILE).unlink()
|
||||
|
||||
def close(self):
|
||||
print('close db')
|
||||
self.remove_file()
|
||||
self.delete_db_if_empty()
|
||||
|
||||
|
@ -74,7 +74,7 @@ class UpdateDialog(QtWidgets.QDialog):
|
||||
label_text += '<p>Could not determine if this version is newer, please update manually (if necessary).</p>'
|
||||
dialog_bttns = QtWidgets.QDialogButtonBox.Close
|
||||
elif is_updateble:
|
||||
label_text += '<p>Newer version available. Press Ok to download new version, Cancel to ignore.</p>'
|
||||
label_text += '<p>Different version available. Press Ok to download this version, Cancel to ignore.</p>'
|
||||
dialog_bttns = QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel
|
||||
else:
|
||||
label_text += '<p>Version may be already up-to-date.</p>'
|
||||
@ -136,7 +136,7 @@ class QRestartWindow(QtWidgets.QMessageBox):
|
||||
self.setIcon(QtWidgets.QMessageBox.Warning)
|
||||
else:
|
||||
self.setText('Download completed!')
|
||||
self.setInformativeText("Press Restart to use new version now")
|
||||
self.setInformativeText("Press Restart to use new AppImage")
|
||||
self.setDetailedText(f'Location of AppImage: {file_loc}')
|
||||
|
||||
self.setIcon(QtWidgets.QMessageBox.Information)
|
||||
|
@ -82,6 +82,9 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
)
|
||||
|
||||
self.__backup_path = pathlib.Path(bck_file)
|
||||
if os.getenv('APPIMAGE'):
|
||||
# ignore AppImages if not running from AppImage
|
||||
self.look_for_update()
|
||||
|
||||
def _init_gui(self):
|
||||
self.setupUi(self)
|
||||
@ -1017,9 +1020,10 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
@staticmethod
|
||||
@QtCore.pyqtSlot(name='on_actionDocumentation_triggered')
|
||||
def open_doc():
|
||||
docpath = '/autohome/dominik/auswerteprogramm3/doc/_build/html/index.html'
|
||||
import webbrowser
|
||||
webbrowser.open(docpath)
|
||||
pass
|
||||
# docpath = '/autohome/dominik/auswerteprogramm3/doc/_build/html/index.html'
|
||||
# import webbrowser
|
||||
# webbrowser.open(docpath)
|
||||
|
||||
def dropEvent(self, evt):
|
||||
if evt.mimeData().hasUrls():
|
||||
@ -1106,7 +1110,6 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
QLog(parent=self).show()
|
||||
|
||||
def autosave(self) -> bool:
|
||||
# TODO better separate thread may it takes some time to save
|
||||
self.status.setText('Autosave...')
|
||||
success = NMRWriter(self.management.graphs, self.management.data).export(self.__backup_path.with_suffix('.nmr.0'))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user