mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-20 17:29:56 +00:00
In this feature target option must allways point to section name instead of type. Type will be read from type option. In case if type option is not presented it will try to check if section with architecture exists (e.g. target = email, section = email:x86_64); if it does, the correct section name and type will be used. Otherwise it will check if the specified section exists; if it does, seection name and type will be returned.
56 lines
2.0 KiB
Python
56 lines
2.0 KiB
Python
#
|
|
# Copyright (c) 2021 ahriman team.
|
|
#
|
|
# This file is part of ahriman
|
|
# (see https://github.com/arcan1s/ahriman).
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
from pathlib import Path
|
|
from typing import Iterable
|
|
|
|
from ahriman.core.configuration import Configuration
|
|
from ahriman.core.upload.upload import Upload
|
|
from ahriman.core.util import check_output
|
|
from ahriman.models.package import Package
|
|
|
|
|
|
class Rsync(Upload):
|
|
"""
|
|
rsync wrapper
|
|
:ivar command: command arguments for sync
|
|
:ivar remote: remote address to sync
|
|
"""
|
|
|
|
_check_output = check_output
|
|
|
|
def __init__(self, architecture: str, configuration: Configuration, section: str) -> None:
|
|
"""
|
|
default constructor
|
|
:param architecture: repository architecture
|
|
:param configuration: configuration instance
|
|
:param section: settings section name
|
|
"""
|
|
Upload.__init__(self, architecture, configuration)
|
|
self.command = configuration.getlist(section, "command")
|
|
self.remote = configuration.get(section, "remote")
|
|
|
|
def sync(self, path: Path, built_packages: Iterable[Package]) -> None:
|
|
"""
|
|
sync data to remote server
|
|
:param path: local path to sync
|
|
:param built_packages: list of packages which has just been built
|
|
"""
|
|
Rsync._check_output(*self.command, str(path), self.remote, exception=None, logger=self.logger)
|