Add error message when Borg binary is missing. Fixes #333 (#480)

* Add error message when Borg binary is missing. Fixes #333
* Test failures. Stick with PyQt 5.14 for now.
* Clarify exclude file placeholder text. Fixes #314
This commit is contained in:
Manu 2020-06-01 16:02:38 +08:00 committed by GitHub
parent 6bad1bccf8
commit 09b697e395
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 19 deletions

View File

@ -33,7 +33,7 @@ setup_requires =
install_requires =
appdirs
paramiko
pyqt5
pyqt5 < 5.15
peewee
python-dateutil
apscheduler

View File

@ -2,16 +2,18 @@ import os
import sys
import sip
from PyQt5 import QtCore
from PyQt5.QtWidgets import QMessageBox
from vorta.borg.create import BorgCreateThread
from vorta.borg.version import BorgVersionThread
from vorta.config import STATE_DIR
from .borg.create import BorgCreateThread
from .i18n import init_translations, translate
from .models import BackupProfileModel, SettingsModel
from .qt_single_application import QtSingleApplication
from .scheduler import VortaScheduler
from .tray_menu import TrayMenu
from .utils import borg_compat, parse_args
from .views.main_window import MainWindow
from vorta.i18n import init_translations, translate
from vorta.models import BackupProfileModel, SettingsModel
from vorta.qt_single_application import QtSingleApplication
from vorta.scheduler import VortaScheduler
from vorta.tray_menu import TrayMenu
from vorta.utils import borg_compat, parse_args
from vorta.views.main_window import MainWindow
APP_ID = os.path.join(STATE_DIR, "socket")
@ -110,13 +112,29 @@ class VortaApp(QtSingleApplication):
def set_borg_details_action(self):
params = BorgVersionThread.prepare()
if not params['ok']:
self._alert_missing_borg()
return
thread = BorgVersionThread(params['cmd'], params, parent=self)
thread.result.connect(self.set_borg_details_result)
thread.start()
def set_borg_details_result(self, result):
borg_compat.set_version(result['data']['version'], result['data']['path'])
if self._main_window_exists():
self.main_window.miscTab.set_borg_details(borg_compat.version, borg_compat.path)
self.main_window.repoTab.toggle_available_compression()
"""
Receive result from BorgVersionThread. If MainWindow is open, set the version in misc tab.
If no valid version was found, display an error.
"""
if 'version' in result['data']:
borg_compat.set_version(result['data']['version'], result['data']['path'])
if self._main_window_exists():
self.main_window.miscTab.set_borg_details(borg_compat.version, borg_compat.path)
self.main_window.repoTab.toggle_available_compression()
else:
self._alert_missing_borg()
def _alert_missing_borg(self):
msg = QMessageBox()
msg.setIcon(QMessageBox.Critical)
msg.setText(self.tr("No Borg Binary Found"))
msg.setInformativeText(self.tr("Vorta was unable to locate a usable Borg Backup binary."))
msg.setStandardButtons(QMessageBox.Ok)
msg.exec_()

View File

@ -100,7 +100,7 @@
<string/>
</property>
<property name="placeholderText">
<string>**/.DS_Store</string>
<string>E.g. **/.DS_Store</string>
</property>
</widget>
</item>
@ -113,7 +113,7 @@
</sizepolicy>
</property>
<property name="placeholderText">
<string>.nobackup</string>
<string>E.g. CACHE or .nobackup</string>
</property>
</widget>
</item>

View File

@ -13,7 +13,7 @@ import peewee as pw
from playhouse.migrate import SqliteMigrator, migrate
from vorta.i18n import trans_late
from vorta.utils import is_system_tray_available, slugify
from vorta.utils import slugify
SCHEMA_VERSION = 14
@ -346,8 +346,6 @@ def init_db(con=None):
# Create missing settings and update labels. Leave setting values untouched.
for setting in get_misc_settings():
s, created = SettingsModel.get_or_create(key=setting['key'], defaults=setting)
if created and setting['key'] == "enable_notifications_success":
s.value = not bool(is_system_tray_available())
s.label = setting['label']
s.save()

View File

@ -12,4 +12,4 @@ def test_add_folder(qapp, qtbot, tmpdir, monkeypatch, choose_file_dialog):
tab = main.sourceTab
qtbot.mouseClick(tab.sourceAddFolder, QtCore.Qt.LeftButton)
qtbot.waitUntil(lambda: tab.sourceFilesWidget.count() == 2)
qtbot.waitUntil(lambda: tab.sourceFilesWidget.count() == 2, timeout=5000)