kiwi-el8/kiwi/data_sync.py
Marcus Schäfer 40e6308aa9 Port application from python 2.7 to 3.4
For new applications like this kiwi version and its use cases
it is better to base it on a more recent python version
2016-02-17 22:38:38 +01:00

46 lines
1.4 KiB
Python

# Copyright (c) 2015 SUSE Linux GmbH. All rights reserved.
#
# This file is part of kiwi.
#
# kiwi 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.
#
# kiwi 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 kiwi. If not, see <http://www.gnu.org/licenses/>
#
# project
from .command import Command
class DataSync(object):
"""
sync data from a source directory to a target directory
using the rsync protocol
"""
def __init__(self, source_dir, target_dir):
self.source_dir = source_dir
self.target_dir = target_dir
def sync_data(self, exclude=None):
exclude_options = []
if exclude:
for item in exclude:
exclude_options.append('--exclude')
exclude_options.append(
'/' + item
)
Command.run(
[
'rsync', '-a', '-H', '-X', '-A', '--one-file-system'
] + exclude_options + [
self.source_dir, self.target_dir
]
)