mirror of https://github.com/borgbase/vorta
Fix flake8 warnings.
This commit is contained in:
parent
2f0bc7d70e
commit
8659336f5d
15
setup.cfg
15
setup.cfg
|
@ -61,20 +61,9 @@ filterwarnings =
|
|||
[coverage:run]
|
||||
source = src
|
||||
|
||||
[mypy]
|
||||
ignore_missing_imports = true
|
||||
|
||||
|
||||
[flake8]
|
||||
# please note that the values are adjusted so that they do not cause failures
|
||||
# with existing code. if you want to change them, you should first fix all
|
||||
# flake8 failures that appear with your change.
|
||||
ignore =
|
||||
W503,
|
||||
F401,F821,F841,
|
||||
E712
|
||||
# line length long term target: 120
|
||||
max-line-length = 150
|
||||
ignore = W503
|
||||
max-line-length = 120
|
||||
exclude = build,dist,.git,.idea,.cache,.tox
|
||||
|
||||
[tox:tox]
|
||||
|
|
|
@ -6,12 +6,13 @@ from vorta.models import init_db
|
|||
from vorta.application import VortaApp
|
||||
from vorta.config import SETTINGS_DIR
|
||||
from vorta.updater import get_updater
|
||||
import vorta.sentry
|
||||
|
||||
|
||||
def main():
|
||||
# Send crashes to Sentry.
|
||||
if not os.environ.get('NO_SENTRY', False):
|
||||
import vorta.sentry
|
||||
vorta.sentry.init()
|
||||
|
||||
# Init database
|
||||
sqlite_db = peewee.SqliteDatabase(os.path.join(SETTINGS_DIR, 'settings.db'))
|
||||
|
|
|
@ -64,7 +64,7 @@ class BorgCreateThread(BorgThread):
|
|||
if current_wifi is not None:
|
||||
wifi_is_disallowed = WifiSettingModel.select().where(
|
||||
(WifiSettingModel.ssid == current_wifi)
|
||||
& (WifiSettingModel.allowed == False)
|
||||
& (WifiSettingModel.allowed is False)
|
||||
& (WifiSettingModel.profile == profile.id)
|
||||
)
|
||||
if wifi_is_disallowed.count() > 0 and profile.repo.is_remote_repo():
|
||||
|
|
|
@ -32,7 +32,13 @@ class VortaScheduler(QtScheduler):
|
|||
self.reschedule_job(job_id, trigger=trigger)
|
||||
changed = True
|
||||
elif trigger is not None:
|
||||
self.add_job(func=self.create_backup, args=[profile.id], trigger=trigger, id=job_id, misfire_grace_time=180)
|
||||
self.add_job(
|
||||
func=self.create_backup,
|
||||
args=[profile.id],
|
||||
trigger=trigger,
|
||||
id=job_id,
|
||||
misfire_grace_time=180
|
||||
)
|
||||
changed = True
|
||||
elif self.get_job(job_id) is not None and trigger is None:
|
||||
self.remove_job(job_id)
|
||||
|
|
|
@ -24,6 +24,7 @@ def scrub_sensitive_data(event, hint):
|
|||
return event
|
||||
|
||||
|
||||
sentry_sdk.init("https://a4a23df3e44743d5b5c5f06417a9a809@sentry.io/1311799",
|
||||
release=__version__,
|
||||
before_send=scrub_sensitive_data)
|
||||
def init():
|
||||
sentry_sdk.init("https://a4a23df3e44743d5b5c5f06417a9a809@sentry.io/1311799",
|
||||
release=__version__,
|
||||
before_send=scrub_sensitive_data)
|
||||
|
|
|
@ -12,7 +12,7 @@ def get_updater():
|
|||
from objc import loadBundle
|
||||
bundle_path = os.path.join(os.path.dirname(sys.executable), os.pardir, 'Frameworks', 'Sparkle.framework')
|
||||
loadBundle('Sparkle', globals(), bundle_path)
|
||||
sparkle = SUUpdater.sharedUpdater()
|
||||
sparkle = SUUpdater.sharedUpdater() # noqa: F821
|
||||
sparkle.setAutomaticallyChecksForUpdates_(True)
|
||||
sparkle.setAutomaticallyDownloadsUpdates_(False)
|
||||
sparkle.checkForUpdatesInBackground()
|
||||
|
|
|
@ -5,7 +5,6 @@ from paramiko.rsakey import RSAKey
|
|||
from paramiko.ecdsakey import ECDSAKey
|
||||
from paramiko.ed25519key import Ed25519Key
|
||||
from paramiko import SSHException
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5.QtWidgets import QFileDialog
|
||||
from PyQt5 import QtCore
|
||||
import subprocess
|
||||
|
@ -21,7 +20,10 @@ class VortaKeyring(keyring.backend.KeyringBackend):
|
|||
|
||||
def set_password(self, service, repo_url, password):
|
||||
from .models import RepoPassword
|
||||
keyring_entry, created = RepoPassword.get_or_create(url=repo_url, defaults={'password': password})
|
||||
keyring_entry, created = RepoPassword.get_or_create(
|
||||
url=repo_url,
|
||||
defaults={'password': password}
|
||||
)
|
||||
keyring_entry.password = password
|
||||
keyring_entry.save()
|
||||
|
||||
|
@ -75,7 +77,9 @@ def get_private_keys():
|
|||
for key in os.listdir(ssh_folder):
|
||||
for key_format in key_formats:
|
||||
try:
|
||||
parsed_key = key_format.from_private_key_file(os.path.join(ssh_folder, key))
|
||||
parsed_key = key_format.from_private_key_file(
|
||||
os.path.join(ssh_folder, key)
|
||||
)
|
||||
key_details = {
|
||||
'filename': key,
|
||||
'format': parsed_key.get_name(),
|
||||
|
@ -115,18 +119,20 @@ def get_asset(path):
|
|||
|
||||
def get_sorted_wifis(profile):
|
||||
"""Get SSIDs from OS and merge with settings in DB."""
|
||||
app = QApplication.instance()
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
plist_file = open('/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist', 'rb')
|
||||
plist_path = '/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist'
|
||||
plist_file = open(plist_path, 'rb')
|
||||
wifis = plistlib.load(plist_file)['KnownNetworks']
|
||||
if wifis:
|
||||
for wifi in wifis.values():
|
||||
timestamp = wifi.get('LastConnected', None)
|
||||
ssid = wifi['SSIDString']
|
||||
db_wifi, created = WifiSettingModel.get_or_create(ssid=ssid, profile=profile.id,
|
||||
defaults={'last_connected': timestamp,
|
||||
'allowed': True})
|
||||
db_wifi, created = WifiSettingModel.get_or_create(
|
||||
ssid=ssid,
|
||||
profile=profile.id,
|
||||
defaults={'last_connected': timestamp, 'allowed': True}
|
||||
)
|
||||
|
||||
# update last connected time
|
||||
if not created and db_wifi.last_connected != timestamp:
|
||||
|
@ -134,11 +140,13 @@ def get_sorted_wifis(profile):
|
|||
db_wifi.save()
|
||||
|
||||
# remove Wifis that were deleted in the system.
|
||||
deleted_wifis = WifiSettingModel.select().where(WifiSettingModel.ssid.not_in([w['SSIDString'] for w in wifis.values()]))
|
||||
deleted_wifis = WifiSettingModel.select() \
|
||||
.where(WifiSettingModel.ssid.not_in([w['SSIDString'] for w in wifis.values()]))
|
||||
for wifi in deleted_wifis:
|
||||
wifi.delete_instance()
|
||||
|
||||
return WifiSettingModel.select().where(WifiSettingModel.profile == profile.id).order_by(-WifiSettingModel.last_connected)
|
||||
return WifiSettingModel.select() \
|
||||
.where(WifiSettingModel.profile == profile.id).order_by(-WifiSettingModel.last_connected)
|
||||
|
||||
|
||||
def get_current_wifi():
|
||||
|
|
Loading…
Reference in New Issue