mirror of https://gitlab.com/KKlochko/tui-rsync
parent
70f60ff715
commit
f708cdf3d4
@ -0,0 +1,5 @@
|
|||||||
|
from .backup_command_port import BackupCommandPort
|
||||||
|
from .backup_sync_command import BackupSyncCommand
|
||||||
|
from .backup_sync_command_dry_run import BackupSyncCommandDryRun
|
||||||
|
|
||||||
|
__all__ = ['BackupCommandPort', 'BackupSyncCommand', 'BackupSyncCommandDryRun']
|
@ -0,0 +1,7 @@
|
|||||||
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
|
|
||||||
|
class BackupCommandPort(ABC):
|
||||||
|
@abstractmethod
|
||||||
|
def run(self):
|
||||||
|
pass
|
@ -0,0 +1,14 @@
|
|||||||
|
import shlex
|
||||||
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
|
from . import BackupCommandPort
|
||||||
|
|
||||||
|
|
||||||
|
class BackupSyncCommand(BackupCommandPort):
|
||||||
|
def __init__(self, source: str, destination: str, args: str):
|
||||||
|
self._args = ["rsync"] + shlex.split(args) + [source, destination]
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
output = Popen(self._args, stdout=PIPE)
|
||||||
|
response = output.communicate()
|
||||||
|
|
@ -0,0 +1,14 @@
|
|||||||
|
import shlex
|
||||||
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
|
from . import BackupCommandPort
|
||||||
|
|
||||||
|
|
||||||
|
class BackupSyncCommandDryRun(BackupCommandPort):
|
||||||
|
def __init__(self, source: str, destination: str, args: str):
|
||||||
|
self._args = ["rsync"] + shlex.split(args) + ['--dry-run', source, destination]
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
output = Popen(self._args, stdout=PIPE)
|
||||||
|
return output.communicate()
|
||||||
|
|
Loading…
Reference in new issue