mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-15 06:55:48 +00:00
add more tests
This commit is contained in:
@ -30,6 +30,8 @@ class Dump(Handler):
|
||||
dump config handler
|
||||
"""
|
||||
|
||||
_print = print
|
||||
|
||||
@classmethod
|
||||
def run(cls: Type[Handler], args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
"""
|
||||
@ -40,7 +42,7 @@ class Dump(Handler):
|
||||
"""
|
||||
config_dump = config.dump(architecture)
|
||||
for section, values in sorted(config_dump.items()):
|
||||
print(f"[{section}]")
|
||||
Dump._print(f"[{section}]")
|
||||
for key, value in sorted(values.items()):
|
||||
print(f"{key} = {value}")
|
||||
print()
|
||||
Dump._print(f"{key} = {value}")
|
||||
Dump._print()
|
||||
|
@ -25,7 +25,7 @@ from typing import Dict, Iterable, List, Optional
|
||||
from ahriman.core.build_tools.task import Task
|
||||
from ahriman.core.report.report import Report
|
||||
from ahriman.core.repository.cleaner import Cleaner
|
||||
from ahriman.core.upload.uploader import Uploader
|
||||
from ahriman.core.upload.upload import Upload
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
@ -118,7 +118,7 @@ class Executor(Cleaner):
|
||||
if targets is None:
|
||||
targets = self.config.getlist("upload", "target")
|
||||
for target in targets:
|
||||
Uploader.run(self.architecture, self.config, target, self.paths.repository)
|
||||
Upload.run(self.architecture, self.config, target, self.paths.repository)
|
||||
|
||||
def process_update(self, packages: Iterable[Path]) -> Path:
|
||||
"""
|
||||
|
@ -20,11 +20,11 @@
|
||||
from pathlib import Path
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.upload.uploader import Uploader
|
||||
from ahriman.core.upload.upload import Upload
|
||||
from ahriman.core.util import check_output
|
||||
|
||||
|
||||
class Rsync(Uploader):
|
||||
class Rsync(Upload):
|
||||
"""
|
||||
rsync wrapper
|
||||
:ivar remote: remote address to sync
|
||||
@ -38,7 +38,7 @@ class Rsync(Uploader):
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
"""
|
||||
Uploader.__init__(self, architecture, config)
|
||||
Upload.__init__(self, architecture, config)
|
||||
section = config.get_section_name("rsync", architecture)
|
||||
self.remote = config.get(section, "remote")
|
||||
|
||||
|
@ -20,11 +20,11 @@
|
||||
from pathlib import Path
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.upload.uploader import Uploader
|
||||
from ahriman.core.upload.upload import Upload
|
||||
from ahriman.core.util import check_output
|
||||
|
||||
|
||||
class S3(Uploader):
|
||||
class S3(Upload):
|
||||
"""
|
||||
aws-cli wrapper
|
||||
:ivar bucket: full bucket name
|
||||
@ -38,7 +38,7 @@ class S3(Uploader):
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
"""
|
||||
Uploader.__init__(self, architecture, config)
|
||||
Upload.__init__(self, architecture, config)
|
||||
section = config.get_section_name("s3", architecture)
|
||||
self.bucket = config.get(section, "bucket")
|
||||
|
||||
|
@ -26,7 +26,7 @@ from ahriman.core.exceptions import SyncFailed
|
||||
from ahriman.models.upload_settings import UploadSettings
|
||||
|
||||
|
||||
class Uploader:
|
||||
class Upload:
|
||||
"""
|
||||
base remote sync class
|
||||
:ivar architecture: repository architecture
|
||||
@ -56,17 +56,17 @@ class Uploader:
|
||||
provider = UploadSettings.from_option(target)
|
||||
if provider == UploadSettings.Rsync:
|
||||
from ahriman.core.upload.rsync import Rsync
|
||||
uploader: Uploader = Rsync(architecture, config)
|
||||
upload: Upload = Rsync(architecture, config)
|
||||
elif provider == UploadSettings.S3:
|
||||
from ahriman.core.upload.s3 import S3
|
||||
uploader = S3(architecture, config)
|
||||
upload = S3(architecture, config)
|
||||
else:
|
||||
uploader = Uploader(architecture, config)
|
||||
upload = Upload(architecture, config)
|
||||
|
||||
try:
|
||||
uploader.sync(path)
|
||||
upload.sync(path)
|
||||
except Exception:
|
||||
uploader.logger.exception(f"remote sync failed for {provider.name}")
|
||||
upload.logger.exception(f"remote sync failed for {provider.name}")
|
||||
raise SyncFailed()
|
||||
|
||||
def sync(self, path: Path) -> None:
|
@ -31,7 +31,7 @@ from typing import Any, Dict, List, Optional, Set, Type, Union
|
||||
from ahriman.core.alpm.pacman import Pacman
|
||||
from ahriman.core.exceptions import InvalidPackageInfo
|
||||
from ahriman.core.util import check_output
|
||||
from ahriman.models.package_desciption import PackageDescription
|
||||
from ahriman.models.package_description import PackageDescription
|
||||
from ahriman.models.repository_paths import RepositoryPaths
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user