From 5975be2ca5f9fd44b3dd0dd2c725b9833439da2e Mon Sep 17 00:00:00 2001 From: cclecle Date: Fri, 29 Mar 2024 03:34:56 +0000 Subject: [PATCH 1/9] chore: update project keywords --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e5899cd..4be028e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ name = "dabdatasync" description = "dabdatasync" readme = "README.md" requires-python = ">=3.11" -keywords = ["chacha","chacha","template","dabdatasync"] +keywords = ["chacha","dabdatasync","dab","debian","proxmox","pydabfactory"] license = { file = "LICENSE.md" } authors = [ From 842b8b6a5c44732606b801834848901f027540d2 Mon Sep 17 00:00:00 2001 From: cclecle Date: Fri, 29 Mar 2024 12:15:40 +0000 Subject: [PATCH 2/9] fix main --- src/dabdatasync/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dabdatasync/__main__.py b/src/dabdatasync/__main__.py index 4ab0b31..2e5cc16 100644 --- a/src/dabdatasync/__main__.py +++ b/src/dabdatasync/__main__.py @@ -148,8 +148,8 @@ def fct_main(i_args: list[str]) -> None: # pylint: disable=too-many-branches,to def CLI(): """wrapper for .toml declared script""" - fct_main(sys.argv) + fct_main(sys.argv[1:]) if __name__ == "__main__": - fct_main(sys.argv[1:]) + CLI() From da10ea2c190bd9b446ea7989a4b22289c06261a0 Mon Sep 17 00:00:00 2001 From: cclecle Date: Sun, 31 Mar 2024 00:36:10 +0000 Subject: [PATCH 3/9] feat: improve help for subparsers --- src/dabdatasync/__main__.py | 37 +++++++++++++++++++++++++--------- src/dabdatasync/compressors.py | 6 +++++- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/dabdatasync/__main__.py b/src/dabdatasync/__main__.py index 2e5cc16..94f5b46 100644 --- a/src/dabdatasync/__main__.py +++ b/src/dabdatasync/__main__.py @@ -17,9 +17,10 @@ import sys from tap import Tap from loguru import logger -from . import __Summuary__, __Name__ +from . import __Summuary__, __Name__,__version__ from . import datasync from . import exceptions +from . import compressors class dabdatasync_args_GetServices(Tap): @@ -36,7 +37,7 @@ class dabdatasync_args_service_abstract(Tap): service: Optional[str] = None def configure(self) -> None: - self.add_argument("--service") + self.add_argument("--service",help=f"specify the service to use (availables: {datasync.DataSync_Factory.get_list()}, first found in priority if not set)") class dabdatasync_args_service_compress_abstract(dabdatasync_args_service_abstract): @@ -46,7 +47,7 @@ class dabdatasync_args_service_compress_abstract(dabdatasync_args_service_abstra def configure(self) -> None: super().configure() - self.add_argument("--compressor") + self.add_argument("--compressor",help=f"specify the compressor method (availables: {compressors.DataSync_Compressors.get_list()}, .tar.gz if not set)") class dabdatasync_args_PullData(dabdatasync_args_service_compress_abstract): @@ -64,12 +65,16 @@ class dabdatasync_args_WipeRemoteData(dabdatasync_args_service_abstract): class dabdatasync_args(Tap): """Main CLI arg parser""" - verbosity: int = 0 - + verbosity: int = 0 + help: bool = False + version: bool = False + def configure(self) -> None: - self.add_argument("-v", "--verbosity", action="count", help="increase output verbosity") + self.add_argument("--version", action="store_true", help="show version string") + self.add_argument("-h", "--help", action="store_true", help="full help") + self.add_argument("-v", "--verbosity", action="count", help="increase output verbosity") - self.add_subparsers(dest="command", help="command type", required=True) + self.add_subparsers(dest="command", help="command type") self.add_subparser("GetServices", dabdatasync_args_GetServices, help="Get registered services list") self.add_subparser("PullData", dabdatasync_args_PullData, help="Pull data from the service") self.add_subparser("PushData", dabdatasync_args_PushData, help="Push data to the service") @@ -86,7 +91,21 @@ def fct_main(i_args: list[str]) -> None: # pylint: disable=too-many-branches,to parser: dabdatasync_args = dabdatasync_args(prog=__Name__, description=__Summuary__) args: dabdatasync_args = parser.parse_args(i_args) - + + if args.help or args.version: + print(f"{__Name__} version {__version__}") + + if args.help: + print(parser.format_help()) + + for name, subparser in parser._subparsers.choices.items(): + print("=========================") + print(f"Subparser {{{name}}}") + print(subparser.format_help()) + + if args.help or args.version: + exit(0) + logger.remove() if args.verbosity: if args.verbosity == 1: @@ -143,7 +162,7 @@ def fct_main(i_args: list[str]) -> None: # pylint: disable=too-many-branches,to selected_dabdatasync.wipe_remote_data() return - raise RuntimeError("Invalid argument") + raise RuntimeError("a command is required") def CLI(): diff --git a/src/dabdatasync/compressors.py b/src/dabdatasync/compressors.py index a6293f9..9ecbc45 100644 --- a/src/dabdatasync/compressors.py +++ b/src/dabdatasync/compressors.py @@ -75,7 +75,11 @@ class DataSync_Compressors: if len(found) == 1: return found[0] raise DataSyncException_TooManyCompressorFound() - + + @classmethod + def get_list(cls) -> list[str]: + """return the available compressor name list""" + return [ _.compressor_name for _ in cls._availables] @DataSync_Compressors.register class DataSync_Compressor__tar_gz(A_DataSync_Compressor): From 9581772c9eb401ea42a35430556a70e1cb64c2c1 Mon Sep 17 00:00:00 2001 From: cclecle Date: Sun, 31 Mar 2024 00:36:34 +0000 Subject: [PATCH 4/9] chore: extract nextcloud password from source files --- .gitignore | 3 ++- test/test_datasync.py | 26 +++++++++++++++++++++- test/test_manifest_nextcloud.json | 2 +- test/test_manifest_nextcloud_disabled.json | 2 +- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index e395bb1..5a2134f 100644 --- a/.gitignore +++ b/.gitignore @@ -43,4 +43,5 @@ helpers-results /.mypy_cache/ .coverage .mypy_cache -test/tmp \ No newline at end of file +test/tmp +test/nextcloud_pwd.mdp \ No newline at end of file diff --git a/test/test_datasync.py b/test/test_datasync.py index 7212d23..5a280d5 100644 --- a/test/test_datasync.py +++ b/test/test_datasync.py @@ -10,9 +10,12 @@ import unittest from os import chdir, path as os_path from pathlib import Path import pprint +import os +import glob from io import StringIO from contextlib import redirect_stdout, redirect_stderr import shutil +import json from contexttimer import Timer print(__name__) @@ -32,7 +35,28 @@ class TestDabDataSync(unittest.TestCase): shutil.rmtree(testdir_path / "test_data2", ignore_errors=True) shutil.copytree(testdir_path / "test_data_origin", testdir_path / "test_data") shutil.copytree(testdir_path / "test_data_origin", testdir_path / "test_data2") - + + nextcloud_pwd="" + if 'nextcloud_pwd' in os.environ: + nextcloud_pwd = os.environ.get("nextcloud_pwd") + elif os.path.isfile(testdir_path / "nextcloud_pwd.mdp"): + with open(testdir_path / "nextcloud_pwd.mdp","rt",encoding="utf-8") as pwd_file: + nextcloud_pwd=pwd_file.read() + else: + raise RuntimeError("NextCloud pwd file not found") + files = glob.glob(str(testdir_path / "test_data" / "*.json")) + files += glob.glob(str(testdir_path / "test_data2" / "*.json")) + for file in files: + with open(file) as f: + data = json.load(f) + try: + data["Args"]["FSSync_NextCloud_Password"]["value"] = nextcloud_pwd + except Exception as exc: + print(f"ignoring exception: {exc}") + os.remove(file) + with open(file, 'w') as f: + json.dump(data, f) + def tearDown(self) -> None: shutil.rmtree(testdir_path / "test_data", ignore_errors=True) shutil.rmtree(testdir_path / "test_data2", ignore_errors=True) diff --git a/test/test_manifest_nextcloud.json b/test/test_manifest_nextcloud.json index 1fea9ae..92bda2c 100644 --- a/test/test_manifest_nextcloud.json +++ b/test/test_manifest_nextcloud.json @@ -254,7 +254,7 @@ }, "FSSync_NextCloud_Password": { "type": "STRING", - "value": "F3P8m-nQHik-NSmb2-mnFEF-s85RE" + "value": "" }, "FSSync_NextCloud_Path": { "type": "STRING", diff --git a/test/test_manifest_nextcloud_disabled.json b/test/test_manifest_nextcloud_disabled.json index 7395f41..ebca5fc 100644 --- a/test/test_manifest_nextcloud_disabled.json +++ b/test/test_manifest_nextcloud_disabled.json @@ -4,6 +4,6 @@ "FSSync_NextCloud_Enabled": {"type": "BOOL", "value": false}, "FSSync_NextCloud_Address": {"type": "URL", "value": "https://chacha.ddns.net/nextcloud"}, "FSSync_NextCloud_User": {"type": "STRING", "value": "chacha-bot"}, -"FSSync_NextCloud_Password": {"type": "STRING", "value": "F3P8m-nQHik-NSmb2-mnFEF-s85RE"}, +"FSSync_NextCloud_Password": {"type": "STRING", "value": ""}, "FSSync_NextCloud_Path": {"type": "STRING", "value": "pydabfactory"} }} \ No newline at end of file From f4ac5360b7d1f82b5332fdd198e552761a2626d2 Mon Sep 17 00:00:00 2001 From: cclecle Date: Sun, 31 Mar 2024 00:45:55 +0000 Subject: [PATCH 5/9] fix nextcloud password setting add missing function for help --- src/dabdatasync/datasync.py | 6 ++++++ src/dabdatasync/datasync_nextcloud.py | 1 + test/test_datasync.py | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/dabdatasync/datasync.py b/src/dabdatasync/datasync.py index 461b57f..15bcf72 100644 --- a/src/dabdatasync/datasync.py +++ b/src/dabdatasync/datasync.py @@ -33,6 +33,7 @@ class A_DataSync(ABC): """Abstract DataSync class""" service_name: str = "ABSTRACT" + priority: int = 0 @classmethod @final @@ -178,3 +179,8 @@ class DataSync_Factory: """decorator to register a concrete class to the factory""" cls.ar_cls_DataSync.add(_cls) return _cls + + @classmethod + def get_list(cls) -> list[str]: + """return the available DataSync concrete class name list""" + return [ _.service_name for _ in cls.ar_cls_DataSync] diff --git a/src/dabdatasync/datasync_nextcloud.py b/src/dabdatasync/datasync_nextcloud.py index 0f2b02d..7801fc8 100644 --- a/src/dabdatasync/datasync_nextcloud.py +++ b/src/dabdatasync/datasync_nextcloud.py @@ -32,6 +32,7 @@ class C_DataSync_NextCloud(A_DataSync): """Concrete DataSync class - Nextcloud""" service_name: str = "Nextcloud" + priority: int = 100 def __init__(self, manifest: dict[Any, Any], cls_compressor: type[A_DataSync_Compressor]) -> None: super().__init__(manifest, cls_compressor) diff --git a/test/test_datasync.py b/test/test_datasync.py index 5a280d5..7d63545 100644 --- a/test/test_datasync.py +++ b/test/test_datasync.py @@ -44,8 +44,8 @@ class TestDabDataSync(unittest.TestCase): nextcloud_pwd=pwd_file.read() else: raise RuntimeError("NextCloud pwd file not found") - files = glob.glob(str(testdir_path / "test_data" / "*.json")) - files += glob.glob(str(testdir_path / "test_data2" / "*.json")) + files = glob.glob(str(testdir_path / "*.json")) + files += glob.glob(str(testdir_path /"*.json")) for file in files: with open(file) as f: data = json.load(f) From f9c03a83f33b9f97413d8eec783ae0daaac9dfd5 Mon Sep 17 00:00:00 2001 From: cclecle Date: Sun, 31 Mar 2024 02:04:08 +0100 Subject: [PATCH 6/9] chore: fix export and nextcloud pwd script test: fix typing --- src/dabdatasync/__main__.py | 2 +- test/test_datasync.py | 6 +- test/test_manifest_empty.json | 3 +- test/test_manifest_invalid.json | 3 +- test/test_manifest_nextcloud.json | 1040 ++++++++++---------- test/test_manifest_nextcloud_disabled.json | 32 +- test/test_manifest_nextcloud_invalid.json | 12 +- 7 files changed, 560 insertions(+), 538 deletions(-) diff --git a/src/dabdatasync/__main__.py b/src/dabdatasync/__main__.py index 94f5b46..45c4acb 100644 --- a/src/dabdatasync/__main__.py +++ b/src/dabdatasync/__main__.py @@ -98,7 +98,7 @@ def fct_main(i_args: list[str]) -> None: # pylint: disable=too-many-branches,to if args.help: print(parser.format_help()) - for name, subparser in parser._subparsers.choices.items(): + for name, subparser in parser._subparsers.choices.items(): # type: ignore[union-attr] print("=========================") print(f"Subparser {{{name}}}") print(subparser.format_help()) diff --git a/test/test_datasync.py b/test/test_datasync.py index 7d63545..1a7bf2d 100644 --- a/test/test_datasync.py +++ b/test/test_datasync.py @@ -51,11 +51,11 @@ class TestDabDataSync(unittest.TestCase): data = json.load(f) try: data["Args"]["FSSync_NextCloud_Password"]["value"] = nextcloud_pwd - except Exception as exc: - print(f"ignoring exception: {exc}") + except Exception: + pass os.remove(file) with open(file, 'w') as f: - json.dump(data, f) + json.dump(data, f, sort_keys=True, indent=4) def tearDown(self) -> None: shutil.rmtree(testdir_path / "test_data", ignore_errors=True) diff --git a/test/test_manifest_empty.json b/test/test_manifest_empty.json index eb7449b..d1eaf0c 100644 --- a/test/test_manifest_empty.json +++ b/test/test_manifest_empty.json @@ -1,3 +1,4 @@ { "APP_ID": "2a13dff2-1298-11ee-be56-0242ac120002", - "Args": {}} \ No newline at end of file + "Args": {} +} \ No newline at end of file diff --git a/test/test_manifest_invalid.json b/test/test_manifest_invalid.json index db38982..c4eb76f 100644 --- a/test/test_manifest_invalid.json +++ b/test/test_manifest_invalid.json @@ -1,2 +1,3 @@ { - "APP_ID": "2a13dff2-1298-11ee-be56-0242ac120002"} \ No newline at end of file + "APP_ID": "2a13dff2-1298-11ee-be56-0242ac120002" +} \ No newline at end of file diff --git a/test/test_manifest_nextcloud.json b/test/test_manifest_nextcloud.json index 92bda2c..c7e672b 100644 --- a/test/test_manifest_nextcloud.json +++ b/test/test_manifest_nextcloud.json @@ -1,541 +1,541 @@ { - "APP_NAME": "CHACHA-SOTF", - "APP_DESC": "ChaCha SonOfTheForset Dedicated Server", - "APP_ID": "2a13dff2-1298-11ee-be56-0242ac120002", - "REFERENCE_CONFIG_ID": "cf698a62-120a-11ee-be56-0242ac120002", - "VIRTUAL": false, - "NOBOOTSTRAP": false, - "NOFINALIZE": false, - "NOSTART": false, - "creation_date": "2024-03-24T19:07:48.862542", - "Params": { - "ROOTFS_SIZE_G": { - "value": 20, - "modified": true - }, - "AR_TAGS": { - "value": [ - { - "value": "pydabfactory" + "APP_DESC": "ChaCha SonOfTheForset Dedicated Server", + "APP_ID": "2a13dff2-1298-11ee-be56-0242ac120002", + "APP_NAME": "CHACHA-SOTF", + "Args": { + "ACLSavePath": { + "type": "STRING", + "value": "/saved.acl" }, - { - "value": "debianbase" + "AnimalSpawnRate": { + "type": "STRING", + "value": "Normal" }, - { - "value": "pydabfactory" - }, - { - "value": "chacha" - }, - { - "value": "pydabfactory" - }, - { - "value": "games" - }, - { - "value": "pydabfactory" - }, - { - "value": "sotf" - } - ], - "modified": true - }, - "FEATURE_NESTING": { - "value": false, - "modified": false - }, - "MAIN_MACADDR": { - "value": "D2:A9:59:72:C4:B4", - "modified": true - }, - "AUTOSTART": { - "value": true, - "modified": true - }, - "CPU_UNIT": { - "value": 1536, - "modified": true - }, - "PRIVILEGIED": { - "value": false, - "modified": false - }, - "DEST_NODE": { - "value": "hypervisor2", - "modified": true - }, - "SWAP_M": { - "value": 2048, - "modified": true - }, - "AR_CFG_OPT": { - "value": [], - "modified": false - }, - "RUNNING_STORAGE": { - "value": "VMStore2", - "modified": true - }, - "FEATURE_FUSE": { - "value": false, - "modified": false - }, - "FEATURE_MKNODE": { - "value": false, - "modified": false - }, - "NETWORK_BRIDGE": { - "value": "vmbr1", - "modified": true - }, - "CPU_COUNT": { - "value": 2, - "modified": true - }, - "TEMPLATE_STORAGE": { - "value": "live-storage-h2", - "modified": true - }, - "RAM_M": { - "value": 12000, - "modified": true - } - }, - "Args": { - "RootPasswd": { - "type": "ROOT_PASSWD", - "value": "######" - }, - "DEBUG_TOOLS": { - "type": "BOOL", - "value": false - }, - "SSH_PORT": { - "type": "LISTEN_PORT", - "value": { - "port_type": { - "type": "STRING", - "value": "tcp" - }, - "value": { - "type": "UINT", - "value": 50020 - } - } - }, - "FirstBootFilePath": { - "type": "STRING", - "value": "/firstboot.sh" - }, - "CustomFirstBootFilePath": { - "type": "STRING", - "value": "/customfirstboot.sh" - }, - "ACLSavePath": { - "type": "STRING", - "value": "/saved.acl" - }, - "locale": { - "type": "STRING", - "value": "fr_FR.UTF-8" - }, - "locale_gen": { - "type": "STRING", - "value": "fr_FR.UTF-8 UTF-8" - }, - "timezone": { - "type": "STRING", - "value": "Europe/Paris" - }, - "EnableLog2Ram": { - "type": "BOOL", - "value": false - }, - "EnableAutoReboot": { - "type": "BOOL", - "value": true - }, - "EnableJava": { - "type": "BOOL", - "value": false - }, - "ForcePython39": { - "type": "BOOL", - "value": false - }, - "EXEC_USER": { - "type": "STRING", - "value": "GenUser" - }, - "EXEC_USER_ID": { - "type": "UINT", - "value": 1000 - }, - "EXEC_USER_PASSWD": { - "type": "PASSWD", - "value": "######" - }, - "DEFAULT_CHACHA_GIT_BRANCH": { - "type": "STRING", - "value": "production" - }, - "SECTION": { - "type": "STRING", - "value": "games" - }, - "SystemDJournalMaxSize": { - "type": "STRING", - "value": "40M" - }, - "FSSYNC_PRESYNC_CMD": { - "type": "STRING", - "value": "" - }, - "FSSYNC_POSTSYNC_CMD": { - "type": "STRING", - "value": "" - }, - "FSSYNC_INITIAL_FETCH": { - "type": "BOOL", - "value": true - }, - "FSSYNC_RECORD": { - "type": "T_ARRAY_FSSYNC_RECORD", - "value": [ - { - "type": "T_FSSYNC_RECORD", - "value": { - "name": { - "type": "SIMPLE_STRING", - "value": "SOTF_map" - }, - "type": { - "type": "SIMPLE_STRING", - "value": "fs" - }, + "BlobSyncPort": { + "type": "EXT_LISTEN_PORT", "value": { - "type": "STRING", - "value": "test/test_data" + "port_type": { + "type": "STRING", + "value": "udp" + }, + "value": { + "type": "UINT", + "value": 9700 + } } - } }, - { - "type": "T_FSSYNC_RECORD", - "value": { - "name": { - "type": "SIMPLE_STRING", - "value": "SOTF_map2" - }, - "type": { - "type": "SIMPLE_STRING", - "value": "fs" - }, + "CPUQUOTA": { + "type": "SYSTEMD_CPUQUOTA", + "value": 98 + }, + "ColdPenalties": { + "type": "STRING", + "value": "Off" + }, + "ConsumableEffects": { + "type": "STRING", + "value": "Normal" + }, + "CustomFirstBootFilePath": { + "type": "STRING", + "value": "/customfirstboot.sh" + }, + "DAB_EXT_LISTEN_PORTS": { + "type": "AR_EXT_LISTEN_PORT", + "value": [ + { + "type": "EXT_LISTEN_PORT", + "value": { + "port_type": { + "type": "STRING", + "value": "udp" + }, + "value": { + "type": "UINT", + "value": 8766 + } + } + }, + { + "type": "EXT_LISTEN_PORT", + "value": { + "port_type": { + "type": "STRING", + "value": "udp" + }, + "value": { + "type": "UINT", + "value": 27018 + } + } + }, + { + "type": "EXT_LISTEN_PORT", + "value": { + "port_type": { + "type": "STRING", + "value": "udp" + }, + "value": { + "type": "UINT", + "value": 9700 + } + } + } + ] + }, + "DAB_LISTEN_PORTS": { + "type": "AR_LISTEN_PORT", + "value": [ + { + "type": "LISTEN_PORT", + "value": { + "port_type": { + "type": "STRING", + "value": "tcp" + }, + "value": { + "type": "UINT", + "value": 50020 + } + } + } + ] + }, + "DAB_MOUNT_POINTS": { + "type": "AR_MOUNT_POINT", + "value": [] + }, + "DAB_SHARED_MOUNT_POINTS": { + "type": "AR_MOUNT_POINT", + "value": [] + }, + "DEBUG_TOOLS": { + "type": "BOOL", + "value": false + }, + "DEFAULT_CHACHA_GIT_BRANCH": { + "type": "STRING", + "value": "production" + }, + "DayLength": { + "type": "STRING", + "value": "Default" + }, + "ENABLE_WINE_ESYNC": { + "type": "BOOL", + "value": false + }, + "ENABLE_WINE_FSYNC": { + "type": "BOOL", + "value": true + }, + "ENABLE_WINE_PRELOADER": { + "type": "BOOL", + "value": false + }, + "EXEC_USER": { + "type": "STRING", + "value": "GenUser" + }, + "EXEC_USER_ID": { + "type": "UINT", + "value": 1000 + }, + "EXEC_USER_PASSWD": { + "type": "PASSWD", + "value": "######" + }, + "EnableAutoReboot": { + "type": "BOOL", + "value": true + }, + "EnableJava": { + "type": "BOOL", + "value": false + }, + "EnableLog2Ram": { + "type": "BOOL", + "value": false + }, + "EnemyAggression": { + "type": "STRING", + "value": "Normal" + }, + "EnemyArmour": { + "type": "STRING", + "value": "Normal" + }, + "EnemyDamage": { + "type": "STRING", + "value": "Normal" + }, + "EnemyHealth": { + "type": "STRING", + "value": "Normal" + }, + "EnemySpawn": { + "type": "BOOL", + "value": true + }, + "FSSYNC_INITIAL_FETCH": { + "type": "BOOL", + "value": true + }, + "FSSYNC_POSTSYNC_CMD": { + "type": "STRING", + "value": "" + }, + "FSSYNC_PRESYNC_CMD": { + "type": "STRING", + "value": "" + }, + "FSSYNC_RECORD": { + "type": "T_ARRAY_FSSYNC_RECORD", + "value": [ + { + "type": "T_FSSYNC_RECORD", + "value": { + "name": { + "type": "SIMPLE_STRING", + "value": "SOTF_map" + }, + "type": { + "type": "SIMPLE_STRING", + "value": "fs" + }, + "value": { + "type": "STRING", + "value": "test/test_data" + } + } + }, + { + "type": "T_FSSYNC_RECORD", + "value": { + "name": { + "type": "SIMPLE_STRING", + "value": "SOTF_map2" + }, + "type": { + "type": "SIMPLE_STRING", + "value": "fs" + }, + "value": { + "type": "STRING", + "value": "test/test_data2/SAVE_FILE.txt" + } + } + } + ] + }, + "FSSync_NextCloud_Address": { + "type": "URL", + "value": "https://chacha.ddns.net/nextcloud" + }, + "FSSync_NextCloud_Enabled": { + "type": "BOOL", + "value": true + }, + "FSSync_NextCloud_Password": { + "type": "STRING", + "value": "F3P8m-nQHik-NSmb2-mnFEF-s85RE" + }, + "FSSync_NextCloud_Path": { + "type": "STRING", + "value": "pydabfactory-test" + }, + "FSSync_NextCloud_User": { + "type": "STRING", + "value": "chacha-bot" + }, + "FirstBootFilePath": { + "type": "STRING", + "value": "/firstboot.sh" + }, + "ForcePython39": { + "type": "BOOL", + "value": false + }, + "GAMETYPENAME": { + "type": "STRING", + "value": "sotf" + }, + "GAME_MNG_DEFAULT_MODE": { + "type": "STRING", + "value": "BLACKLIST" + }, + "GAME_MNG_LISTENING_PORT": { + "type": "UINT", + "value": 50000 + }, + "GAME_MNG_PWD": { + "type": "STRING", + "value": "cfographut" + }, + "GAME_MNG_RESTART_DELAY": { + "type": "UINT", + "value": 30 + }, + "GamePassword": { + "type": "STRING", + "value": "!bourges2023" + }, + "GamePort": { + "type": "EXT_LISTEN_PORT", "value": { - "type": "STRING", - "value": "test/test_data2/SAVE_FILE.txt" + "port_type": { + "type": "STRING", + "value": "udp" + }, + "value": { + "type": "UINT", + "value": 8766 + } } - } - } - ] - }, - "FSSync_NextCloud_Enabled": { - "type": "BOOL", - "value": true - }, - "FSSync_NextCloud_Address": { - "type": "URL", - "value": "https://chacha.ddns.net/nextcloud" - }, - "FSSync_NextCloud_User": { - "type": "STRING", - "value": "chacha-bot" - }, - "FSSync_NextCloud_Password": { - "type": "STRING", - "value": "" - }, - "FSSync_NextCloud_Path": { - "type": "STRING", - "value": "pydabfactory-test" - }, - "GAME_MNG_PWD": { - "type": "STRING", - "value": "cfographut" - }, - "GAME_MNG_DEFAULT_MODE": { - "type": "STRING", - "value": "BLACKLIST" - }, - "GAME_MNG_LISTENING_PORT": { - "type": "UINT", - "value": 50000 - }, - "GAME_MNG_RESTART_DELAY": { - "type": "UINT", - "value": 30 - }, - "GAMETYPENAME": { - "type": "STRING", - "value": "sotf" - }, - "WINE_ARCH": { - "type": "STRING", - "value": "win64" - }, - "WINE_NAME": { - "type": "STRING", - "value": "wine-9.4-staging-tkg-amd64" - }, - "WINEPREFIX": { - "type": "STRING", - "value": "DEFAULT" - }, - "WINE_URL": { - "type": "URL", - "value": "https://github.com/Kron4ek/Wine-Builds/releases/download/9.4/wine-9.4-staging-tkg-amd64.tar.xz" - }, - "ENABLE_WINE_ESYNC": { - "type": "BOOL", - "value": false - }, - "ENABLE_WINE_FSYNC": { - "type": "BOOL", - "value": true - }, - "ENABLE_WINE_PRELOADER": { - "type": "BOOL", - "value": false - }, - "MEMLIMITHIGH": { - "type": "SYSTEMD_RAM", - "value": "10G" - }, - "MEMLIMITMAX": { - "type": "SYSTEMD_RAM", - "value": "11G" - }, - "CPUQUOTA": { - "type": "SYSTEMD_CPUQUOTA", - "value": 98 - }, - "STEAM_APP_ID": { - "type": "UINT", - "value": 2465200 - }, - "STEAM_LOGIN": { - "type": "STRING", - "value": "cclecle" - }, - "STEAM_PWD": { - "type": "PASSWD", - "value": "######" - }, - "HostName": { - "type": "STRING", - "value": "ChaCha - Sons Of The Forest Server" - }, - "MaxPlayers": { - "type": "UINT", - "value": 8 - }, - "GamePassword": { - "type": "STRING", - "value": "!bourges2023" - }, - "GamePort": { - "type": "EXT_LISTEN_PORT", - "value": { - "port_type": { - "type": "STRING", - "value": "udp" }, - "value": { - "type": "UINT", - "value": 8766 - } - } - }, - "QueryPort": { - "type": "EXT_LISTEN_PORT", - "value": { - "port_type": { - "type": "STRING", - "value": "udp" + "HostName": { + "type": "STRING", + "value": "ChaCha - Sons Of The Forest Server" }, - "value": { - "type": "UINT", - "value": 27018 - } - } - }, - "BlobSyncPort": { - "type": "EXT_LISTEN_PORT", - "value": { - "port_type": { - "type": "STRING", - "value": "udp" + "LanOnly": { + "type": "BOOL", + "value": false }, - "value": { - "type": "UINT", - "value": 9700 - } - } - }, - "LanOnly": { - "type": "BOOL", - "value": false - }, - "SaveSlot": { - "type": "UINT", - "value": 1 - }, - "SaveInterval": { - "type": "UINT", - "value": 600 - }, - "TreeRegrowth": { - "type": "BOOL", - "value": true - }, - "StructureDamage": { - "type": "BOOL", - "value": false - }, - "EnemySpawn": { - "type": "BOOL", - "value": true - }, - "SkipNetworkAccessibilityTest": { - "type": "BOOL", - "value": true - }, - "EnemyHealth": { - "type": "STRING", - "value": "Normal" - }, - "EnemyDamage": { - "type": "STRING", - "value": "Normal" - }, - "EnemyArmour": { - "type": "STRING", - "value": "Normal" - }, - "EnemyAggression": { - "type": "STRING", - "value": "Normal" - }, - "AnimalSpawnRate": { - "type": "STRING", - "value": "Normal" - }, - "StartingSeason": { - "type": "STRING", - "value": "Summer" - }, - "SeasonLength": { - "type": "STRING", - "value": "Default" - }, - "DayLength": { - "type": "STRING", - "value": "Default" - }, - "PrecipitationFrequency": { - "type": "STRING", - "value": "Default" - }, - "ConsumableEffects": { - "type": "STRING", - "value": "Normal" - }, - "PlayerStatsDamage": { - "type": "STRING", - "value": "Off" - }, - "ColdPenalties": { - "type": "STRING", - "value": "Off" - }, - "ReducedFoodInContainers": { - "type": "BOOL", - "value": false - }, - "SingleUseContainers": { - "type": "BOOL", - "value": false - }, - "DAB_LISTEN_PORTS": { - "type": "AR_LISTEN_PORT", - "value": [ - { - "type": "LISTEN_PORT", - "value": { - "port_type": { - "type": "STRING", - "value": "tcp" - }, + "MEMLIMITHIGH": { + "type": "SYSTEMD_RAM", + "value": "10G" + }, + "MEMLIMITMAX": { + "type": "SYSTEMD_RAM", + "value": "11G" + }, + "MaxPlayers": { + "type": "UINT", + "value": 8 + }, + "PlayerStatsDamage": { + "type": "STRING", + "value": "Off" + }, + "PrecipitationFrequency": { + "type": "STRING", + "value": "Default" + }, + "QueryPort": { + "type": "EXT_LISTEN_PORT", "value": { - "type": "UINT", - "value": 50020 + "port_type": { + "type": "STRING", + "value": "udp" + }, + "value": { + "type": "UINT", + "value": 27018 + } } - } - } - ] - }, - "DAB_EXT_LISTEN_PORTS": { - "type": "AR_EXT_LISTEN_PORT", - "value": [ - { - "type": "EXT_LISTEN_PORT", - "value": { - "port_type": { - "type": "STRING", - "value": "udp" - }, - "value": { - "type": "UINT", - "value": 8766 - } - } }, - { - "type": "EXT_LISTEN_PORT", - "value": { - "port_type": { - "type": "STRING", - "value": "udp" - }, - "value": { - "type": "UINT", - "value": 27018 - } - } + "ReducedFoodInContainers": { + "type": "BOOL", + "value": false }, - { - "type": "EXT_LISTEN_PORT", - "value": { - "port_type": { - "type": "STRING", - "value": "udp" - }, + "RootPasswd": { + "type": "ROOT_PASSWD", + "value": "######" + }, + "SECTION": { + "type": "STRING", + "value": "games" + }, + "SSH_PORT": { + "type": "LISTEN_PORT", "value": { - "type": "UINT", - "value": 9700 + "port_type": { + "type": "STRING", + "value": "tcp" + }, + "value": { + "type": "UINT", + "value": 50020 + } } - } + }, + "STEAM_APP_ID": { + "type": "UINT", + "value": 2465200 + }, + "STEAM_LOGIN": { + "type": "STRING", + "value": "cclecle" + }, + "STEAM_PWD": { + "type": "PASSWD", + "value": "######" + }, + "SaveInterval": { + "type": "UINT", + "value": 600 + }, + "SaveSlot": { + "type": "UINT", + "value": 1 + }, + "SeasonLength": { + "type": "STRING", + "value": "Default" + }, + "SingleUseContainers": { + "type": "BOOL", + "value": false + }, + "SkipNetworkAccessibilityTest": { + "type": "BOOL", + "value": true + }, + "StartingSeason": { + "type": "STRING", + "value": "Summer" + }, + "StructureDamage": { + "type": "BOOL", + "value": false + }, + "SystemDJournalMaxSize": { + "type": "STRING", + "value": "40M" + }, + "TreeRegrowth": { + "type": "BOOL", + "value": true + }, + "WINEPREFIX": { + "type": "STRING", + "value": "DEFAULT" + }, + "WINE_ARCH": { + "type": "STRING", + "value": "win64" + }, + "WINE_NAME": { + "type": "STRING", + "value": "wine-9.4-staging-tkg-amd64" + }, + "WINE_URL": { + "type": "URL", + "value": "https://github.com/Kron4ek/Wine-Builds/releases/download/9.4/wine-9.4-staging-tkg-amd64.tar.xz" + }, + "locale": { + "type": "STRING", + "value": "fr_FR.UTF-8" + }, + "locale_gen": { + "type": "STRING", + "value": "fr_FR.UTF-8 UTF-8" + }, + "timezone": { + "type": "STRING", + "value": "Europe/Paris" } - ] }, - "DAB_MOUNT_POINTS": { - "type": "AR_MOUNT_POINT", - "value": [] + "NOBOOTSTRAP": false, + "NOFINALIZE": false, + "NOSTART": false, + "Params": { + "AR_CFG_OPT": { + "modified": false, + "value": [] + }, + "AR_TAGS": { + "modified": true, + "value": [ + { + "value": "pydabfactory" + }, + { + "value": "debianbase" + }, + { + "value": "pydabfactory" + }, + { + "value": "chacha" + }, + { + "value": "pydabfactory" + }, + { + "value": "games" + }, + { + "value": "pydabfactory" + }, + { + "value": "sotf" + } + ] + }, + "AUTOSTART": { + "modified": true, + "value": true + }, + "CPU_COUNT": { + "modified": true, + "value": 2 + }, + "CPU_UNIT": { + "modified": true, + "value": 1536 + }, + "DEST_NODE": { + "modified": true, + "value": "hypervisor2" + }, + "FEATURE_FUSE": { + "modified": false, + "value": false + }, + "FEATURE_MKNODE": { + "modified": false, + "value": false + }, + "FEATURE_NESTING": { + "modified": false, + "value": false + }, + "MAIN_MACADDR": { + "modified": true, + "value": "D2:A9:59:72:C4:B4" + }, + "NETWORK_BRIDGE": { + "modified": true, + "value": "vmbr1" + }, + "PRIVILEGIED": { + "modified": false, + "value": false + }, + "RAM_M": { + "modified": true, + "value": 12000 + }, + "ROOTFS_SIZE_G": { + "modified": true, + "value": 20 + }, + "RUNNING_STORAGE": { + "modified": true, + "value": "VMStore2" + }, + "SWAP_M": { + "modified": true, + "value": 2048 + }, + "TEMPLATE_STORAGE": { + "modified": true, + "value": "live-storage-h2" + } }, - "DAB_SHARED_MOUNT_POINTS": { - "type": "AR_MOUNT_POINT", - "value": [] - } - } + "REFERENCE_CONFIG_ID": "cf698a62-120a-11ee-be56-0242ac120002", + "VIRTUAL": false, + "creation_date": "2024-03-24T19:07:48.862542" } \ No newline at end of file diff --git a/test/test_manifest_nextcloud_disabled.json b/test/test_manifest_nextcloud_disabled.json index ebca5fc..7a27b72 100644 --- a/test/test_manifest_nextcloud_disabled.json +++ b/test/test_manifest_nextcloud_disabled.json @@ -1,9 +1,25 @@ -{ +{ "APP_ID": "2a13dff2-1298-11ee-be56-0242ac120002", - "Args": { -"FSSync_NextCloud_Enabled": {"type": "BOOL", "value": false}, -"FSSync_NextCloud_Address": {"type": "URL", "value": "https://chacha.ddns.net/nextcloud"}, -"FSSync_NextCloud_User": {"type": "STRING", "value": "chacha-bot"}, -"FSSync_NextCloud_Password": {"type": "STRING", "value": ""}, -"FSSync_NextCloud_Path": {"type": "STRING", "value": "pydabfactory"} -}} \ No newline at end of file + "Args": { + "FSSync_NextCloud_Address": { + "type": "URL", + "value": "https://chacha.ddns.net/nextcloud" + }, + "FSSync_NextCloud_Enabled": { + "type": "BOOL", + "value": false + }, + "FSSync_NextCloud_Password": { + "type": "STRING", + "value": "F3P8m-nQHik-NSmb2-mnFEF-s85RE" + }, + "FSSync_NextCloud_Path": { + "type": "STRING", + "value": "pydabfactory" + }, + "FSSync_NextCloud_User": { + "type": "STRING", + "value": "chacha-bot" + } + } +} \ No newline at end of file diff --git a/test/test_manifest_nextcloud_invalid.json b/test/test_manifest_nextcloud_invalid.json index 06a30e7..1067d78 100644 --- a/test/test_manifest_nextcloud_invalid.json +++ b/test/test_manifest_nextcloud_invalid.json @@ -1,5 +1,9 @@ -{ +{ "APP_ID": "2a13dff2-1298-11ee-be56-0242ac120002", - "Args": { -"FSSync_NextCloud_Enabled": {"type": "BOOL", "value": true} -}} \ No newline at end of file + "Args": { + "FSSync_NextCloud_Enabled": { + "type": "BOOL", + "value": true + } + } +} \ No newline at end of file From cb4872d0572c37bcccbe3e8141e8182f9a6bc174 Mon Sep 17 00:00:00 2001 From: cclecle Date: Sun, 31 Mar 2024 02:09:41 +0100 Subject: [PATCH 7/9] chore: apply black formater --- src/dabdatasync/__main__.py | 38 +++++++++++++++++++-------------- src/dabdatasync/__metadata__.py | 2 +- src/dabdatasync/compressors.py | 5 +++-- src/dabdatasync/datasync.py | 2 +- test/__init__.py | 2 +- test/test_datasync.py | 18 ++++++++-------- 6 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/dabdatasync/__main__.py b/src/dabdatasync/__main__.py index 45c4acb..a4dfb7e 100644 --- a/src/dabdatasync/__main__.py +++ b/src/dabdatasync/__main__.py @@ -17,7 +17,7 @@ import sys from tap import Tap from loguru import logger -from . import __Summuary__, __Name__,__version__ +from . import __Summuary__, __Name__, __version__ from . import datasync from . import exceptions from . import compressors @@ -37,7 +37,10 @@ class dabdatasync_args_service_abstract(Tap): service: Optional[str] = None def configure(self) -> None: - self.add_argument("--service",help=f"specify the service to use (availables: {datasync.DataSync_Factory.get_list()}, first found in priority if not set)") + self.add_argument( + "--service", + help=f"specify the service to use (availables: {datasync.DataSync_Factory.get_list()}, first found in priority if not set)", + ) class dabdatasync_args_service_compress_abstract(dabdatasync_args_service_abstract): @@ -47,7 +50,10 @@ class dabdatasync_args_service_compress_abstract(dabdatasync_args_service_abstra def configure(self) -> None: super().configure() - self.add_argument("--compressor",help=f"specify the compressor method (availables: {compressors.DataSync_Compressors.get_list()}, .tar.gz if not set)") + self.add_argument( + "--compressor", + help=f"specify the compressor method (availables: {compressors.DataSync_Compressors.get_list()}, .tar.gz if not set)", + ) class dabdatasync_args_PullData(dabdatasync_args_service_compress_abstract): @@ -65,14 +71,14 @@ class dabdatasync_args_WipeRemoteData(dabdatasync_args_service_abstract): class dabdatasync_args(Tap): """Main CLI arg parser""" - verbosity: int = 0 - help: bool = False - version: bool = False - + verbosity: int = 0 + help: bool = False + version: bool = False + def configure(self) -> None: - self.add_argument("--version", action="store_true", help="show version string") - self.add_argument("-h", "--help", action="store_true", help="full help") - self.add_argument("-v", "--verbosity", action="count", help="increase output verbosity") + self.add_argument("--version", action="store_true", help="show version string") + self.add_argument("-h", "--help", action="store_true", help="full help") + self.add_argument("-v", "--verbosity", action="count", help="increase output verbosity") self.add_subparsers(dest="command", help="command type") self.add_subparser("GetServices", dabdatasync_args_GetServices, help="Get registered services list") @@ -91,21 +97,21 @@ def fct_main(i_args: list[str]) -> None: # pylint: disable=too-many-branches,to parser: dabdatasync_args = dabdatasync_args(prog=__Name__, description=__Summuary__) args: dabdatasync_args = parser.parse_args(i_args) - + if args.help or args.version: print(f"{__Name__} version {__version__}") - + if args.help: print(parser.format_help()) - - for name, subparser in parser._subparsers.choices.items(): # type: ignore[union-attr] + + for name, subparser in parser._subparsers.choices.items(): # type: ignore[union-attr] print("=========================") print(f"Subparser {{{name}}}") print(subparser.format_help()) - + if args.help or args.version: exit(0) - + logger.remove() if args.verbosity: if args.verbosity == 1: diff --git a/src/dabdatasync/__metadata__.py b/src/dabdatasync/__metadata__.py index 8ba1eab..a2e9dd1 100644 --- a/src/dabdatasync/__metadata__.py +++ b/src/dabdatasync/__metadata__.py @@ -15,7 +15,7 @@ import warnings try: # pragma: no cover __version__ = version("dabdatasync") -except PackageNotFoundError: # pragma: no cover +except PackageNotFoundError: # pragma: no cover warnings.warn("can not read __version__, assuming local test context, setting it to ?.?.?") __version__ = "?.?.?" diff --git a/src/dabdatasync/compressors.py b/src/dabdatasync/compressors.py index 9ecbc45..ae8db6c 100644 --- a/src/dabdatasync/compressors.py +++ b/src/dabdatasync/compressors.py @@ -75,11 +75,12 @@ class DataSync_Compressors: if len(found) == 1: return found[0] raise DataSyncException_TooManyCompressorFound() - + @classmethod def get_list(cls) -> list[str]: """return the available compressor name list""" - return [ _.compressor_name for _ in cls._availables] + return [_.compressor_name for _ in cls._availables] + @DataSync_Compressors.register class DataSync_Compressor__tar_gz(A_DataSync_Compressor): diff --git a/src/dabdatasync/datasync.py b/src/dabdatasync/datasync.py index 15bcf72..56de217 100644 --- a/src/dabdatasync/datasync.py +++ b/src/dabdatasync/datasync.py @@ -183,4 +183,4 @@ class DataSync_Factory: @classmethod def get_list(cls) -> list[str]: """return the available DataSync concrete class name list""" - return [ _.service_name for _ in cls.ar_cls_DataSync] + return [_.service_name for _ in cls.ar_cls_DataSync] diff --git a/test/__init__.py b/test/__init__.py index a5f7a5a..d0d551c 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -4,4 +4,4 @@ # Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Unported License. # # You should have received a copy of the license along with this -# work. If not, see . \ No newline at end of file +# work. If not, see . diff --git a/test/test_datasync.py b/test/test_datasync.py index 1a7bf2d..45ce3b1 100644 --- a/test/test_datasync.py +++ b/test/test_datasync.py @@ -35,28 +35,28 @@ class TestDabDataSync(unittest.TestCase): shutil.rmtree(testdir_path / "test_data2", ignore_errors=True) shutil.copytree(testdir_path / "test_data_origin", testdir_path / "test_data") shutil.copytree(testdir_path / "test_data_origin", testdir_path / "test_data2") - - nextcloud_pwd="" - if 'nextcloud_pwd' in os.environ: + + nextcloud_pwd = "" + if "nextcloud_pwd" in os.environ: nextcloud_pwd = os.environ.get("nextcloud_pwd") elif os.path.isfile(testdir_path / "nextcloud_pwd.mdp"): - with open(testdir_path / "nextcloud_pwd.mdp","rt",encoding="utf-8") as pwd_file: - nextcloud_pwd=pwd_file.read() + with open(testdir_path / "nextcloud_pwd.mdp", "rt", encoding="utf-8") as pwd_file: + nextcloud_pwd = pwd_file.read() else: raise RuntimeError("NextCloud pwd file not found") files = glob.glob(str(testdir_path / "*.json")) - files += glob.glob(str(testdir_path /"*.json")) + files += glob.glob(str(testdir_path / "*.json")) for file in files: with open(file) as f: - data = json.load(f) + data = json.load(f) try: data["Args"]["FSSync_NextCloud_Password"]["value"] = nextcloud_pwd except Exception: pass os.remove(file) - with open(file, 'w') as f: + with open(file, "w") as f: json.dump(data, f, sort_keys=True, indent=4) - + def tearDown(self) -> None: shutil.rmtree(testdir_path / "test_data", ignore_errors=True) shutil.rmtree(testdir_path / "test_data2", ignore_errors=True) From 7e6aacc82f77a5bddcd1df07a2dc33242a37c5a4 Mon Sep 17 00:00:00 2001 From: cclecle Date: Sun, 31 Mar 2024 02:19:47 +0100 Subject: [PATCH 8/9] fix: properly remove credentials after test --- test/test_datasync.py | 14 ++++++++++++++ test/test_manifest_nextcloud.json | 2 +- test/test_manifest_nextcloud_disabled.json | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/test/test_datasync.py b/test/test_datasync.py index 45ce3b1..cac0a29 100644 --- a/test/test_datasync.py +++ b/test/test_datasync.py @@ -44,6 +44,7 @@ class TestDabDataSync(unittest.TestCase): nextcloud_pwd = pwd_file.read() else: raise RuntimeError("NextCloud pwd file not found") + files = glob.glob(str(testdir_path / "*.json")) files += glob.glob(str(testdir_path / "*.json")) for file in files: @@ -61,6 +62,19 @@ class TestDabDataSync(unittest.TestCase): shutil.rmtree(testdir_path / "test_data", ignore_errors=True) shutil.rmtree(testdir_path / "test_data2", ignore_errors=True) + files = glob.glob(str(testdir_path / "*.json")) + files += glob.glob(str(testdir_path / "*.json")) + for file in files: + with open(file) as f: + data = json.load(f) + try: + data["Args"]["FSSync_NextCloud_Password"]["value"] = "" + except Exception: + pass + os.remove(file) + with open(file, "w") as f: + json.dump(data, f, sort_keys=True, indent=4) + def test_version(self): self.assertNotEqual(dabdatasync.__version__, "?.?.?") diff --git a/test/test_manifest_nextcloud.json b/test/test_manifest_nextcloud.json index c7e672b..78aa0e2 100644 --- a/test/test_manifest_nextcloud.json +++ b/test/test_manifest_nextcloud.json @@ -239,7 +239,7 @@ }, "FSSync_NextCloud_Password": { "type": "STRING", - "value": "F3P8m-nQHik-NSmb2-mnFEF-s85RE" + "value": "" }, "FSSync_NextCloud_Path": { "type": "STRING", diff --git a/test/test_manifest_nextcloud_disabled.json b/test/test_manifest_nextcloud_disabled.json index 7a27b72..0783e5d 100644 --- a/test/test_manifest_nextcloud_disabled.json +++ b/test/test_manifest_nextcloud_disabled.json @@ -11,7 +11,7 @@ }, "FSSync_NextCloud_Password": { "type": "STRING", - "value": "F3P8m-nQHik-NSmb2-mnFEF-s85RE" + "value": "" }, "FSSync_NextCloud_Path": { "type": "STRING", From e95b59ae3d6551d65aec3d6e2f1e09c9426bfd9e Mon Sep 17 00:00:00 2001 From: cclecle Date: Sun, 31 Mar 2024 02:22:42 +0100 Subject: [PATCH 9/9] fix quality report --- src/dabdatasync/__main__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dabdatasync/__main__.py b/src/dabdatasync/__main__.py index a4dfb7e..e5df907 100644 --- a/src/dabdatasync/__main__.py +++ b/src/dabdatasync/__main__.py @@ -92,7 +92,7 @@ class dabdatasync_args(Tap): self.command: Union[str, None] = cast(Union[str, None], self.command) # pylint: disable=attribute-defined-outside-init -def fct_main(i_args: list[str]) -> None: # pylint: disable=too-many-branches,too-complex +def fct_main(i_args: list[str]) -> None: # pylint: disable=too-many-branches,too-complex,too-many-statements """CLI main function""" parser: dabdatasync_args = dabdatasync_args(prog=__Name__, description=__Summuary__) @@ -104,13 +104,13 @@ def fct_main(i_args: list[str]) -> None: # pylint: disable=too-many-branches,to if args.help: print(parser.format_help()) - for name, subparser in parser._subparsers.choices.items(): # type: ignore[union-attr] + for name, subparser in parser._subparsers.choices.items(): # type: ignore[union-attr] # pylint: disable=protected-access print("=========================") print(f"Subparser {{{name}}}") print(subparser.format_help()) if args.help or args.version: - exit(0) + sys.exit(0) logger.remove() if args.verbosity: