10 Commits

Author SHA1 Message Date
6d5cbeed49 Merge pull request 'dev' (#5) from dev into master
Reviewed-on: https://chacha.ddns.net/gitea/chacha/dabdatasync/pulls/5
new-tag:0.4
2024-03-31 13:02:43 +02:00
cclecle
e95b59ae3d fix quality report 2024-03-31 02:22:42 +01:00
cclecle
7e6aacc82f fix: properly remove credentials after test 2024-03-31 02:19:47 +01:00
cclecle
cb4872d057 chore: apply black formater 2024-03-31 02:09:41 +01:00
cclecle
f9c03a83f3 chore: fix export and nextcloud pwd script
test: fix typing
2024-03-31 02:04:08 +01:00
cclecle
f4ac5360b7 fix nextcloud password setting
add missing function for help
2024-03-31 00:45:55 +00:00
636316650e Merge pull request 'dev' (#4) from dev into master
Reviewed-on: https://chacha.ddns.net/gitea/chacha/dabdatasync/pulls/4
new-tag:0.3.0
2024-03-29 04:30:29 +01:00
bfcf65b6e7 Merge pull request 'dev' (#3) from dev into master
Reviewed-on: https://chacha.ddns.net/gitea/chacha/dabdatasync/pulls/3
new-tag:0.2.0
2024-03-28 03:30:02 +01:00
f39fd9cf44 Merge pull request 'import code' (#2) from dev into master
Reviewed-on: https://chacha.ddns.net/gitea/chacha/dabdatasync/pulls/2
new-tag:0.1.0
2024-03-23 13:00:47 +01:00
cclecle
dd45b1281f rename project 2024-03-23 11:45:18 +00:00
13 changed files with 620 additions and 570 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>{{project_name}}</name>
<name>dabdatasync</name>
<comment></comment>
<projects>
</projects>

View File

@@ -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")
@@ -86,26 +92,26 @@ 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__)
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():
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:
if args.verbosity == 1:

View File

@@ -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__ = "?.?.?"

View File

@@ -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):

View File

@@ -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]

View File

@@ -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)

View File

@@ -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 <https://creativecommons.org/licenses/by-nc-sa/4.0/>.
# work. If not, see <https://creativecommons.org/licenses/by-nc-sa/4.0/>.

View File

@@ -35,32 +35,46 @@ 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 / "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)
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)
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)
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__, "?.?.?")

View File

@@ -1,3 +1,4 @@
{
"APP_ID": "2a13dff2-1298-11ee-be56-0242ac120002",
"Args": {}}
"Args": {}
}

View File

@@ -1,2 +1,3 @@
{
"APP_ID": "2a13dff2-1298-11ee-be56-0242ac120002"}
"APP_ID": "2a13dff2-1298-11ee-be56-0242ac120002"
}

File diff suppressed because it is too large Load Diff

View File

@@ -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"}
}}
"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": ""
},
"FSSync_NextCloud_Path": {
"type": "STRING",
"value": "pydabfactory"
},
"FSSync_NextCloud_User": {
"type": "STRING",
"value": "chacha-bot"
}
}
}

View File

@@ -1,5 +1,9 @@
{
{
"APP_ID": "2a13dff2-1298-11ee-be56-0242ac120002",
"Args": {
"FSSync_NextCloud_Enabled": {"type": "BOOL", "value": true}
}}
"Args": {
"FSSync_NextCloud_Enabled": {
"type": "BOOL",
"value": true
}
}
}