1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-22 07:43:09 +00:00

Add link to the logs folder in borg warnings (#1609)

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.
This commit is contained in:
Divyansh Singh 2023-03-12 12:35:46 +05:30 committed by GitHub
parent 961e0b5057
commit 6bc532187b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 7 deletions

View file

@ -9,7 +9,7 @@
from vorta.borg.create import BorgCreateJob from vorta.borg.create import BorgCreateJob
from vorta.borg.jobs_manager import JobsManager from vorta.borg.jobs_manager import JobsManager
from vorta.borg.version import BorgVersionJob 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.i18n import init_translations, translate
from vorta.notifications import VortaNotifications from vorta.notifications import VortaNotifications
from vorta.profile_export import ProfileExport from vorta.profile_export import ProfileExport
@ -326,7 +326,9 @@ def check_failed_response(self, result: Dict[str, Any]):
if returncode == 1: if returncode == 1:
# warning # warning
msg.setIcon(QMessageBox.Icon.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 infotext = error_message
elif returncode > 128: elif returncode > 128:
# 128+N - killed by signal N (e.g. 137 == kill -9) # 128+N - killed by signal N (e.g. 137 == kill -9)

View file

@ -208,6 +208,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="1" alignment="Qt::AlignTop"> <item row="1" column="1" alignment="Qt::AlignTop">

View file

@ -1,4 +1,6 @@
from typing import Any, Dict from typing import Any, Dict
from vorta.config import LOG_DIR
from vorta.i18n import translate
from vorta.utils import borg_compat from vorta.utils import borg_compat
from .borg_job import BorgJob from .borg_job import BorgJob
@ -20,7 +22,11 @@ def finished_event(self, result: Dict[str, Any]):
self.app.backup_finished_event.emit(result) self.app.backup_finished_event.emit(result)
self.result.emit(result) self.result.emit(result)
if result['returncode'] != 0: 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) self.app.check_failed_event.emit(result)
else: else:
self.app.backup_progress_event.emit(self.tr('Check completed.')) self.app.backup_progress_event.emit(self.tr('Check completed.'))

View file

@ -1,5 +1,6 @@
from typing import Any, Dict 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 vorta.utils import borg_compat
from .borg_job import BorgJob from .borg_job import BorgJob
@ -21,7 +22,11 @@ def finished_event(self, result: Dict[str, Any]):
self.app.backup_finished_event.emit(result) self.app.backup_finished_event.emit(result)
self.result.emit(result) self.result.emit(result)
if result['returncode'] != 0: 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: else:
self.app.backup_progress_event.emit(self.tr('Compaction completed.')) self.app.backup_progress_event.emit(self.tr('Compaction completed.'))

View file

@ -2,7 +2,8 @@
import subprocess import subprocess
import tempfile import tempfile
from datetime import datetime as dt 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.store.models import ArchiveModel, RepoModel, SourceFileModel, WifiSettingModel
from vorta.utils import borg_compat, format_archive_name, get_network_status_monitor from vorta.utils import borg_compat, format_archive_name, get_network_status_monitor
from .borg_job import BorgJob from .borg_job import BorgJob
@ -33,7 +34,12 @@ def process_result(self, result):
repo.save() repo.save()
if result['returncode'] == 1: 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: else:
self.app.backup_progress_event.emit(self.tr('Backup finished.')) self.app.backup_progress_event.emit(self.tr('Backup finished.'))