Skip to content

Commit 67499e1

Browse files
authored
Merge branch 'master' into Test-leave-key-in-keyring
2 parents 6afdbbc + 6bc5321 commit 67499e1

10 files changed

Lines changed: 49 additions & 34 deletions

File tree

setup.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ package_dir =
3737
include_package_data = true
3838
python_requires = >=3.7
3939
install_requires =
40-
appdirs
40+
platformdirs >=3.0.0, <4.0.0; sys_platform == 'darwin' # for macOS: breaking changes in 3.0.0,
41+
platformdirs >=2.6.0, <4.0.0; sys_platform != 'darwin' # for others: 2.6+ works consistently.
4142
paramiko
4243
pyqt5
4344
peewee

src/vorta/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def exception_handler(type, value, tb):
5858

5959
# Init database
6060
sqlite_db = SqliteDatabase(
61-
os.path.join(SETTINGS_DIR, 'settings.db'),
61+
SETTINGS_DIR / 'settings.db',
6262
pragmas={
6363
'journal_mode': 'wal',
6464
},

src/vorta/application.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import logging
22
import os
33
import sys
4+
from pathlib import Path
45
from typing import Any, Dict, List, Tuple
56
from PyQt5 import QtCore
67
from PyQt5.QtWidgets import QMessageBox
78
from vorta.borg.break_lock import BorgBreakJob
89
from vorta.borg.create import BorgCreateJob
910
from vorta.borg.jobs_manager import JobsManager
1011
from vorta.borg.version import BorgVersionJob
11-
from vorta.config import PROFILE_BOOTSTRAP_FILE, TEMP_DIR
12+
from vorta.config import LOG_DIR, PROFILE_BOOTSTRAP_FILE, TEMP_DIR
1213
from vorta.i18n import init_translations, translate
1314
from vorta.notifications import VortaNotifications
1415
from vorta.profile_export import ProfileExport
@@ -22,7 +23,7 @@
2223

2324
logger = logging.getLogger(__name__)
2425

25-
APP_ID = os.path.join(TEMP_DIR, "socket")
26+
APP_ID = TEMP_DIR / "socket"
2627

2728

2829
class VortaApp(QtSingleApplication):
@@ -41,7 +42,7 @@ class VortaApp(QtSingleApplication):
4142
check_failed_event = QtCore.pyqtSignal(dict)
4243

4344
def __init__(self, args_raw, single_app=False):
44-
super().__init__(APP_ID, args_raw)
45+
super().__init__(str(APP_ID), args_raw)
4546
args = parse_args()
4647
if self.isRunning():
4748
if single_app:
@@ -193,8 +194,8 @@ def check_darwin_permissions(self):
193194
This function tries reading a file that is known to be restricted and warn the user about
194195
incomplete backups.
195196
"""
196-
test_path = os.path.expanduser('~/Library/Cookies')
197-
if os.path.exists(test_path) and not os.access(test_path, os.R_OK):
197+
test_path = Path('~/Library/Cookies').expanduser()
198+
if test_path.exists() and not os.access(test_path, os.R_OK):
198199
msg = QMessageBox()
199200
msg.setIcon(QMessageBox.Warning)
200201
msg.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse)
@@ -325,7 +326,9 @@ def check_failed_response(self, result: Dict[str, Any]):
325326
if returncode == 1:
326327
# warning
327328
msg.setIcon(QMessageBox.Icon.Warning)
328-
text = self.tr('Borg exited with a warning message. See logs for details.')
329+
text = translate(
330+
'VortaApp', 'Borg exited with warning status (rc 1). See the <a href="{0}">logs</a> for details.'
331+
).format(LOG_DIR.as_uri())
329332
infotext = error_message
330333
elif returncode > 128:
331334
# 128+N - killed by signal N (e.g. 137 == kill -9)

src/vorta/assets/UI/mainwindow.ui

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@
208208
<verstretch>0</verstretch>
209209
</sizepolicy>
210210
</property>
211+
<property name="openExternalLinks">
212+
<bool>true</bool>
213+
</property>
211214
</widget>
212215
</item>
213216
<item row="1" column="1" alignment="Qt::AlignTop">

src/vorta/autostart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def open_app_at_startup(enabled=True):
4747

4848
elif sys.platform.startswith('linux'):
4949
from pathlib import Path
50-
from appdirs import user_config_dir
50+
from platformdirs import user_config_path
5151

5252
is_flatpak = Path('/.flatpak-info').exists()
5353

@@ -58,7 +58,7 @@ def open_app_at_startup(enabled=True):
5858
if is_flatpak:
5959
autostart_path = Path.home() / '.config' / 'autostart'
6060
else:
61-
autostart_path = Path(user_config_dir("autostart"))
61+
autostart_path = user_config_path("autostart")
6262

6363
if not autostart_path.exists():
6464
autostart_path.mkdir(parents=True, exist_ok=True)

src/vorta/borg/check.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from typing import Any, Dict
2+
from vorta.config import LOG_DIR
3+
from vorta.i18n import translate
24
from vorta.utils import borg_compat
35
from .borg_job import BorgJob
46

@@ -20,7 +22,11 @@ def finished_event(self, result: Dict[str, Any]):
2022
self.app.backup_finished_event.emit(result)
2123
self.result.emit(result)
2224
if result['returncode'] != 0:
23-
self.app.backup_progress_event.emit(self.tr('Repo check failed. See logs for details.'))
25+
self.app.backup_progress_event.emit(
26+
translate('RepoCheckJob', 'Repo check failed. See the <a href="{0}">logs</a> for details.').format(
27+
LOG_DIR.as_uri()
28+
)
29+
)
2430
self.app.check_failed_event.emit(result)
2531
else:
2632
self.app.backup_progress_event.emit(self.tr('Check completed.'))

src/vorta/borg/compact.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import Any, Dict
2-
from vorta.i18n import trans_late
2+
from vorta.config import LOG_DIR
3+
from vorta.i18n import trans_late, translate
34
from vorta.utils import borg_compat
45
from .borg_job import BorgJob
56

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

src/vorta/borg/create.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import subprocess
33
import tempfile
44
from datetime import datetime as dt
5-
from vorta.i18n import trans_late
5+
from vorta.config import LOG_DIR
6+
from vorta.i18n import trans_late, translate
67
from vorta.store.models import ArchiveModel, RepoModel, SourceFileModel, WifiSettingModel
78
from vorta.utils import borg_compat, format_archive_name, get_network_status_monitor
89
from .borg_job import BorgJob
@@ -33,7 +34,12 @@ def process_result(self, result):
3334
repo.save()
3435

3536
if result['returncode'] == 1:
36-
self.app.backup_progress_event.emit(self.tr('Backup finished with warnings. See logs for details.'))
37+
self.app.backup_progress_event.emit(
38+
translate(
39+
'BorgCreateJob',
40+
'Backup finished with warnings. See the <a href="{0}">logs</a> for details.',
41+
).format(LOG_DIR.as_uri())
42+
)
3743
else:
3844
self.app.backup_progress_event.emit(self.tr('Backup finished.'))
3945

src/vorta/config.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
1-
import os
21
from pathlib import Path
3-
import appdirs
2+
import platformdirs
43

54
APP_NAME = 'Vorta'
65
APP_AUTHOR = 'BorgBase'
76
APP_ID_DARWIN = 'com.borgbase.client.macos'
8-
dirs = appdirs.AppDirs(APP_NAME, APP_AUTHOR)
9-
SETTINGS_DIR = dirs.user_data_dir
10-
LOG_DIR = dirs.user_log_dir
11-
CACHE_DIR = dirs.user_cache_dir
12-
TEMP_DIR = os.path.join(CACHE_DIR, "tmp")
7+
dirs = platformdirs.PlatformDirs(APP_NAME, APP_AUTHOR)
8+
SETTINGS_DIR = dirs.user_data_path
9+
LOG_DIR = dirs.user_log_path
10+
CACHE_DIR = dirs.user_cache_path
11+
TEMP_DIR = CACHE_DIR / "tmp"
1312
PROFILE_BOOTSTRAP_FILE = Path.home() / '.vorta-init.json'
1413

15-
if not os.path.exists(SETTINGS_DIR):
16-
os.makedirs(SETTINGS_DIR)
1714

18-
if not os.path.exists(LOG_DIR):
19-
os.makedirs(LOG_DIR)
20-
21-
if not os.path.exists(CACHE_DIR):
22-
os.makedirs(CACHE_DIR)
23-
24-
if not os.path.exists(TEMP_DIR):
25-
os.makedirs(TEMP_DIR)
15+
# ensure directories exist
16+
for dir in (SETTINGS_DIR, LOG_DIR, CACHE_DIR, TEMP_DIR):
17+
dir.mkdir(parents=True, exist_ok=True)

src/vorta/log.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"""
88

99
import logging
10-
import os
1110
from logging.handlers import TimedRotatingFileHandler
1211
from .config import LOG_DIR
1312

@@ -23,7 +22,7 @@ def init_logger(background=False):
2322
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
2423

2524
# create handlers
26-
fh = TimedRotatingFileHandler(os.path.join(LOG_DIR, 'vorta.log'), when='d', interval=1, backupCount=5)
25+
fh = TimedRotatingFileHandler(LOG_DIR / 'vorta.log', when='d', interval=1, backupCount=5)
2726
fh.setLevel(logging.DEBUG)
2827
fh.setFormatter(formatter)
2928
logger.addHandler(fh)

0 commit comments

Comments
 (0)