mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
*: Fix all typing hint related errors
- Try to mark class variables in component classes. - Leave typing hints generic, such as 'list' and 'dict' where content is usually not filled, too complex, or context is unimportant. - backups: Handle failure for tarfile extraction so that methods are not called on potentially None valued variables. - backups: Prevent potentially passing a keyword argument twice. - dynamicdns: Deal properly with outcome of urlparsing. - ejabberd: Deal with failed regex match - email: Fix a mypy compliant when iterating a filtered list. - tor: Don't reuse variables for different typed values. - tor: Don't reuse variables for different typed values. - operation: Return None explicitly. - operation: Ensure that keyword argument is not repeated. Tests: - Where only typing hints were modified and no syntax error came up, additional testing was not done. - `mypy --ignore-missing-imports .` run successfully. - Generate developer documentation. - Service runs without errors upon start up. - backups: Listing and restoring specific apps from a backup works. - backups: Mounting a remote backup repository works. - NOT TESTED: dynamicdns: Migrating from old style configuration works. - ejabberd: Verify that setting coturn configuration works. - email: Test that showing configuration from postfix works. - tor: Orport value is properly shown. - transmission: Configuration values are properly set. - users: Running unit tests as root works. - operation: Operation status messages are show properly during app install. - ./setup.py install runs Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
a709f3a6a8
commit
2dd00a8f08
43 files changed
+111
-87
No files matched your search
@@ -6,4 +6,4 @@ Application manifest for backups.
|
||||
# Currently, backup application does not have any settings. However, settings
|
||||
# such as scheduler settings, backup location, secrets to connect to remove
|
||||
# servers need to be backed up.
|
||||
backup = {}
|
||||
backup: dict = {}
|
||||
@@ -31,7 +31,7 @@ def mount(mountpoint: str, remote_path: str, ssh_keyfile: Optional[str] = None,
|
||||
except AlreadyMountedError:
|
||||
return
|
||||
|
||||
kwargs = {}
|
||||
input_ = None
|
||||
# the shell would expand ~/ to the local home directory
|
||||
remote_path = remote_path.replace('~/', '').replace('~', '')
|
||||
# 'reconnect', 'ServerAliveInternal' and 'ServerAliveCountMax' allow the
|
||||
@@ -55,9 +55,9 @@ def mount(mountpoint: str, remote_path: str, ssh_keyfile: Optional[str] = None,
|
||||
if not password:
|
||||
raise ValueError('mount requires either a password or ssh_keyfile')
|
||||
cmd += ['-o', 'password_stdin']
|
||||
kwargs['input'] = password.encode()
|
||||
input_ = password.encode()
|
||||
|
||||
subprocess.run(cmd, check=True, timeout=TIMEOUT, **kwargs)
|
||||
subprocess.run(cmd, check=True, timeout=TIMEOUT, input=input_)
|
||||
|
||||
|
||||
@privileged
|
||||
@@ -266,7 +266,12 @@ def get_exported_archive_apps(path: str) -> list[str]:
|
||||
for name in filenames:
|
||||
if 'var/lib/plinth/backups-manifests/' in name \
|
||||
and name.endswith('.json'):
|
||||
manifest_data = tar_handle.extractfile(name).read()
|
||||
file_handle = tar_handle.extractfile(name)
|
||||
if not file_handle:
|
||||
raise RuntimeError(
|
||||
'Unable to extract app manifest from backup file.')
|
||||
|
||||
manifest_data = file_handle.read()
|
||||
manifest = json.loads(manifest_data)
|
||||
break
|
||||
|
||||
|
||||
@@ -72,9 +72,9 @@ KNOWN_ERRORS = [
|
||||
|
||||
class BaseBorgRepository(abc.ABC):
|
||||
"""Base class for all kinds of Borg repositories."""
|
||||
flags = {}
|
||||
flags: dict[str, bool] = {}
|
||||
is_mounted = True
|
||||
known_credentials = []
|
||||
known_credentials: list[str] = []
|
||||
|
||||
def __init__(self, path, credentials=None, uuid=None, schedule=None,
|
||||
**kwargs):
|
||||
|
||||
Reference in new issue
Block a user