diff --git a/.travis.yml b/.travis.yml index 27c53113..ce6f446a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -74,6 +74,7 @@ before_script: script: - pytest --forked +- if [ $TRAVIS_OS_NAME = "linux" ]; then tox -e flake8; fi #after_script: #- | diff --git a/setup.cfg b/setup.cfg index 3e4f99c5..2950acbc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -63,7 +63,7 @@ filterwarnings = source = src [flake8] -ignore = W503 +ignore = max-line-length = 120 exclude = build,dist,.git,.idea,.cache,.tox,.eggs diff --git a/src/vorta/borg/borg_thread.py b/src/vorta/borg/borg_thread.py index ad62f83d..d8b8bac4 100644 --- a/src/vorta/borg/borg_thread.py +++ b/src/vorta/borg/borg_thread.py @@ -18,7 +18,7 @@ class BorgThread(QtCore.QThread, BackupProfileMixin): """ Base class to run `borg` command line jobs. If a command needs more pre- or post-processing - it should sublass `BorgThread`. + it should subclass `BorgThread`. """ updated = QtCore.pyqtSignal(str) @@ -42,12 +42,14 @@ def __init__(self, cmd, params, parent=None): env = os.environ.copy() env['BORG_HOSTNAME_IS_UNIQUE'] = '1' - if params.get('password') and params['password'] is not None: - env['BORG_PASSPHRASE'] = params['password'] + password = params.get('password') + if password is not None: + env['BORG_PASSPHRASE'] = password env['BORG_RSH'] = 'ssh -oStrictHostKeyChecking=no' - if params.get('ssh_key') and params['ssh_key'] is not None: - env['BORG_RSH'] += f' -i ~/.ssh/{params["ssh_key"]}' + ssh_key = params.get('ssh_key') + if ssh_key is not None: + env['BORG_RSH'] += f' -i ~/.ssh/{ssh_key}' self.env = env self.cmd = cmd diff --git a/src/vorta/borg/create.py b/src/vorta/borg/create.py index 30c4c5a2..0c42d9c3 100644 --- a/src/vorta/borg/create.py +++ b/src/vorta/borg/create.py @@ -63,9 +63,13 @@ def prepare(cls, profile): current_wifi = get_current_wifi() if current_wifi is not None: wifi_is_disallowed = WifiSettingModel.select().where( - (WifiSettingModel.ssid == current_wifi) - & (WifiSettingModel.allowed is False) - & (WifiSettingModel.profile == profile.id) + ( + WifiSettingModel.ssid == current_wifi + ) & ( + WifiSettingModel.allowed is False + ) & ( + WifiSettingModel.profile == profile.id + ) ) if wifi_is_disallowed.count() > 0 and profile.repo.is_remote_repo(): ret['message'] = 'Current Wifi is not allowed.' diff --git a/src/vorta/scheduler.py b/src/vorta/scheduler.py index 6d7cb6a9..7bfdbfe5 100644 --- a/src/vorta/scheduler.py +++ b/src/vorta/scheduler.py @@ -113,9 +113,13 @@ def post_backup_tasks(self, profile_id): validation_cutoff = date.today() - timedelta(days=7 * profile.validation_weeks) recent_validations = EventLogModel.select().where( - (EventLogModel.subcommand == 'check') - & (EventLogModel.start_time > validation_cutoff) - & (EventLogModel.repo_url == profile.repo.url) + ( + EventLogModel.subcommand == 'check' + ) & ( + EventLogModel.start_time > validation_cutoff + ) & ( + EventLogModel.repo_url == profile.repo.url + ) ).count() if profile.validation_on and recent_validations == 0: msg = BorgCheckThread.prepare(profile) diff --git a/src/vorta/updater.py b/src/vorta/updater.py index d219a5ce..bc81b92f 100644 --- a/src/vorta/updater.py +++ b/src/vorta/updater.py @@ -4,11 +4,8 @@ def get_updater(): if sys.platform == 'darwin' and getattr(sys, 'frozen', False): - """ - Use sparkle framework on macOS. - - Examples: https://programtalk.com/python-examples/objc.loadBundle/ - """ + # Use sparkle framework on macOS. + # Examples: https://programtalk.com/python-examples/objc.loadBundle/ from objc import loadBundle bundle_path = os.path.join(os.path.dirname(sys.executable), os.pardir, 'Frameworks', 'Sparkle.framework') loadBundle('Sparkle', globals(), bundle_path) diff --git a/src/vorta/utils.py b/src/vorta/utils.py index 0a96d59b..a6f1335e 100644 --- a/src/vorta/utils.py +++ b/src/vorta/utils.py @@ -39,7 +39,7 @@ def delete_password(self, service, repo_url): pass -"""Select keyring/Workaround for pyinstaller+keyring issue.""" +# Select keyring/Workaround for pyinstaller+keyring issue. if sys.platform == 'darwin': from keyring.backends import OS_X keyring.set_keyring(OS_X.Keyring()) diff --git a/src/vorta/views/archive_tab.py b/src/vorta/views/archive_tab.py index d78bcaab..3eba2980 100644 --- a/src/vorta/views/archive_tab.py +++ b/src/vorta/views/archive_tab.py @@ -1,9 +1,7 @@ import sys from datetime import timedelta from PyQt5 import uic, QtCore -from PyQt5.QtCore import QSize -from PyQt5.QtGui import QIcon -from PyQt5.QtWidgets import QTableWidgetItem, QTableView, QHeaderView, QComboBox, QToolButton, QButtonGroup, QToolBar +from PyQt5.QtWidgets import QTableWidgetItem, QTableView, QHeaderView from vorta.borg.prune import BorgPruneThread from vorta.borg.list import BorgListThread diff --git a/src/vorta/views/collection_rc.py b/src/vorta/views/collection_rc.py index 040b301b..0e1dd6ef 100644 --- a/src/vorta/views/collection_rc.py +++ b/src/vorta/views/collection_rc.py @@ -949,10 +949,13 @@ rcc_version = 2 qt_resource_struct = qt_resource_struct_v2 + def qInitResources(): QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) + def qCleanupResources(): QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) + qInitResources() diff --git a/src/vorta/views/extract_dialog.py b/src/vorta/views/extract_dialog.py index a1e69701..0a3da461 100644 --- a/src/vorta/views/extract_dialog.py +++ b/src/vorta/views/extract_dialog.py @@ -1,11 +1,6 @@ -import os from PyQt5 import uic from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import QApplication, QTreeWidgetItem, QHeaderView - -from paramiko.rsakey import RSAKey -from paramiko.ecdsakey import ECDSAKey -from paramiko.ed25519key import Ed25519Key +from PyQt5.QtWidgets import QTreeWidgetItem, QHeaderView from ..utils import get_asset @@ -13,6 +8,7 @@ ExtractDialogUI, ExtractDialogBase = uic.loadUiType(uifile) n = 0 + class ExtractDialog(ExtractDialogBase, ExtractDialogUI): def __init__(self): super().__init__() @@ -30,7 +26,7 @@ def __init__(self): 'another key2': ['value2', 'value', 'value4']} for j in range(50): d[f'folder-{i}'][f'large folder {j}'] = {'another key1': 'another value1', - 'another key2': ['value2', 'value', 'value4']} + 'another key2': ['value2', 'value', 'value4']} # add top-level folders to test scroll performance for f in range(1000000): @@ -55,6 +51,7 @@ def build_tree(self): fill_item(self.fileTree.invisibleRootItem(), self.d) print('Added test items', n) + def fill_item(item, value): global n # item.setExpanded(True) @@ -67,7 +64,7 @@ def fill_item(item, value): child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setCheckState(0, Qt.Unchecked) item.addChild(child) - n+=1 + n += 1 fill_item(child, val) elif type(value) is list: for val in value: @@ -75,7 +72,7 @@ def fill_item(item, value): child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setCheckState(0, Qt.Unchecked) item.addChild(child) - n+=1 + n += 1 if type(val) is dict: child.setText(0, '[dict]') fill_item(child, val) @@ -90,5 +87,4 @@ def fill_item(item, value): child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setCheckState(0, Qt.Unchecked) item.addChild(child) - n+=1 - + n += 1 diff --git a/src/vorta/views/main_window.py b/src/vorta/views/main_window.py index d08c4cb2..aca80852 100644 --- a/src/vorta/views/main_window.py +++ b/src/vorta/views/main_window.py @@ -110,8 +110,8 @@ def profile_delete_action(self): self.profile_select_action(1) def backup_started_event(self): - self.set_status(progress_max=0) - self._toggle_buttons(create_enabled=False) + self.set_status(progress_max=0) + self._toggle_buttons(create_enabled=False) def backup_finished_event(self): self.set_status(progress_max=100)