Skip to content

Commit

Permalink
Add link to the logs folder in borg warnings (#1609)
Browse files Browse the repository at this point in the history
In case a borg job finishes with warning, vorta will display it and tell the user to have a look in the logs. This adds a clickable link to the log message that opens the default file explorer at the log location.

* src/vorta/application.py (VortaApp.check_failed_response): Improve wording of warning message and link logs.

* src/vorta/borg/create.py (BorgCreateJob.process_result): Link logs.
* src/vorta/borg/compact.py (BorgCompactJob.finished_event): ^^
* src/vorta/borg/check.py (BorgCheckJob.finished_event): ^^

* src/vorta/assets/UI/mainwindow.ui : Enable `openExternalLinks` for `progressText` label.
  • Loading branch information
diivi committed Mar 12, 2023
1 parent 961e0b5 commit 6bc5321
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/vorta/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from vorta.borg.create import BorgCreateJob
from vorta.borg.jobs_manager import JobsManager
from vorta.borg.version import BorgVersionJob
from vorta.config import PROFILE_BOOTSTRAP_FILE, TEMP_DIR
from vorta.config import LOG_DIR, PROFILE_BOOTSTRAP_FILE, TEMP_DIR
from vorta.i18n import init_translations, translate
from vorta.notifications import VortaNotifications
from vorta.profile_export import ProfileExport
Expand Down Expand Up @@ -326,7 +326,9 @@ def check_failed_response(self, result: Dict[str, Any]):
if returncode == 1:
# warning
msg.setIcon(QMessageBox.Icon.Warning)
text = self.tr('Borg exited with a warning message. See logs for details.')
text = translate(
'VortaApp', 'Borg exited with warning status (rc 1). See the <a href="{0}">logs</a> for details.'
).format(LOG_DIR.as_uri())
infotext = error_message
elif returncode > 128:
# 128+N - killed by signal N (e.g. 137 == kill -9)
Expand Down
3 changes: 3 additions & 0 deletions src/vorta/assets/UI/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1" alignment="Qt::AlignTop">
Expand Down
8 changes: 7 additions & 1 deletion src/vorta/borg/check.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Any, Dict
from vorta.config import LOG_DIR
from vorta.i18n import translate
from vorta.utils import borg_compat
from .borg_job import BorgJob

Expand All @@ -20,7 +22,11 @@ def finished_event(self, result: Dict[str, Any]):
self.app.backup_finished_event.emit(result)
self.result.emit(result)
if result['returncode'] != 0:
self.app.backup_progress_event.emit(self.tr('Repo check failed. See logs for details.'))
self.app.backup_progress_event.emit(
translate('RepoCheckJob', 'Repo check failed. See the <a href="{0}">logs</a> for details.').format(
LOG_DIR.as_uri()
)
)
self.app.check_failed_event.emit(result)
else:
self.app.backup_progress_event.emit(self.tr('Check completed.'))
Expand Down
9 changes: 7 additions & 2 deletions src/vorta/borg/compact.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Any, Dict
from vorta.i18n import trans_late
from vorta.config import LOG_DIR
from vorta.i18n import trans_late, translate
from vorta.utils import borg_compat
from .borg_job import BorgJob

Expand All @@ -21,7 +22,11 @@ def finished_event(self, result: Dict[str, Any]):
self.app.backup_finished_event.emit(result)
self.result.emit(result)
if result['returncode'] != 0:
self.app.backup_progress_event.emit(self.tr('Errors during compaction. See logs for details.'))
self.app.backup_progress_event.emit(
translate(
'BorgCompactJob', 'Errors during compaction. See the <a href="{0}">logs</a> for details.'
).format(LOG_DIR.as_uri())
)
else:
self.app.backup_progress_event.emit(self.tr('Compaction completed.'))

Expand Down
10 changes: 8 additions & 2 deletions src/vorta/borg/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import subprocess
import tempfile
from datetime import datetime as dt
from vorta.i18n import trans_late
from vorta.config import LOG_DIR
from vorta.i18n import trans_late, translate
from vorta.store.models import ArchiveModel, RepoModel, SourceFileModel, WifiSettingModel
from vorta.utils import borg_compat, format_archive_name, get_network_status_monitor
from .borg_job import BorgJob
Expand Down Expand Up @@ -33,7 +34,12 @@ def process_result(self, result):
repo.save()

if result['returncode'] == 1:
self.app.backup_progress_event.emit(self.tr('Backup finished with warnings. See logs for details.'))
self.app.backup_progress_event.emit(
translate(
'BorgCreateJob',
'Backup finished with warnings. See the <a href="{0}">logs</a> for details.',
).format(LOG_DIR.as_uri())
)
else:
self.app.backup_progress_event.emit(self.tr('Backup finished.'))

Expand Down

0 comments on commit 6bc5321

Please sign in to comment.