synchroniser : misc pylint suggested fixes
- Do not use mutables as default arguments
- Remove trailing whitespaces
- Initialise using [] and {} instead of list() and dict()
- Use is not None instead of != None
- Some other small stuff
This commit is contained in:
+14
-12
@@ -10,7 +10,6 @@ the remote.
|
||||
import subprocess
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import logging
|
||||
|
||||
from pathlib import Path
|
||||
@@ -50,26 +49,27 @@ class Synchroniser:
|
||||
"""
|
||||
|
||||
def __init__(self, remote:str, local:str, user:str, ip:str, port:int=22,
|
||||
args_bool:list=[], args_value:dict={}, ssh_settings:dict={},
|
||||
backup:BackupConfig | None = None
|
||||
args_bool:list[str] | None = None, args_value:dict[str, str] | None = None,
|
||||
ssh_settings:dict[str, str] | None = None, backup:BackupConfig | None = None
|
||||
):
|
||||
"""Initialises an instance of Synchroniser.
|
||||
"""
|
||||
self.remote_dir:str = remote
|
||||
self.local:str = local
|
||||
self.args_bool:list[str] = args_bool
|
||||
self.args_value:dict[str, str] = args_value
|
||||
self.ssh_settings:dict[str, str] = dict()
|
||||
self.args_bool:list[str] = args_bool if args_bool is not None else []
|
||||
self.args_value:dict[str, str] = args_value if args_value is not None else {}
|
||||
self.ssh_settings:dict[str, str] = ssh_settings if ssh_settings is not None else {}
|
||||
self.remote_user:str = user
|
||||
self.remote_ip:str = ip
|
||||
self.remote_port:int = port
|
||||
self.files_extra:list = list()
|
||||
self.links_extra:list = list()
|
||||
self.files_extra:list = []
|
||||
self.links_extra:list = []
|
||||
self.control_path:str = ""
|
||||
|
||||
if(backup != None and backup.enabled):
|
||||
if backup is not None and backup.enabled:
|
||||
backup = cast(BackupConfig, backup)
|
||||
self.files_extra.append("-backup")
|
||||
if(backup.selection != ""):
|
||||
if backup.selection != "":
|
||||
self.files_extra.append(backup.selection)
|
||||
else:
|
||||
self.files_extra.append("Name *")
|
||||
@@ -92,7 +92,9 @@ class Synchroniser:
|
||||
f"Name {backup.backupprefix[:-1]}"
|
||||
])
|
||||
|
||||
def create_ssh_master_connection(self, control_path:str="~/.ssh/control_%C", connection_timeout:int=60) -> None:
|
||||
def create_ssh_master_connection(self, control_path:str="~/.ssh/control_%C",
|
||||
connection_timeout:int=60
|
||||
) -> None:
|
||||
"""Creates an ssh master connection.
|
||||
|
||||
It is used so the user only has to authenticate once to the remote server.
|
||||
@@ -322,5 +324,5 @@ class Synchroniser:
|
||||
f"{self.remote_user}@{self.remote_ip}:{self.remote_dir}/.data",
|
||||
str(path_to_mount)
|
||||
]
|
||||
completed_process = subprocess.run(command)
|
||||
completed_process = subprocess.run(command, check=True)
|
||||
completed_process.check_returncode()
|
||||
|
||||
Reference in New Issue
Block a user