Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ setup_requires =
install_requires =
appdirs
paramiko
pyqt5
pyqt5 < 5.15
peewee
python-dateutil
apscheduler
Expand Down
42 changes: 30 additions & 12 deletions src/vorta/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
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")

Expand Down Expand Up @@ -110,13 +112,29 @@ def message_received_event_response(self, message):
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_()
4 changes: 2 additions & 2 deletions src/vorta/assets/UI/sourcetab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<string/>
</property>
<property name="placeholderText">
<string>**/.DS_Store</string>
<string>E.g. **/.DS_Store</string>
</property>
</widget>
</item>
Expand All @@ -113,7 +113,7 @@
</sizepolicy>
</property>
<property name="placeholderText">
<string>.nobackup</string>
<string>E.g. CACHE or .nobackup</string>
</property>
</widget>
</item>
Expand Down
4 changes: 1 addition & 3 deletions src/vorta/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
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

Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion tests/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)