parsley.preparation package¶
Submodules¶
parsley.preparation.abstractpreparation module¶
Implement custom preparations by subclassing Preparation
.
-
class
parsley.preparation.abstractpreparation.
Preparation
¶ Bases:
object
Abstract base class for all logic that does preparation work for the actual synchronization run in advance or afterwards (like mounting filesystems, cleaning up stuff).
-
disable
(runtime)¶ Undo the preparation after the synchronization (like unmounting).
- Parameters
runtime (parsley.runtime.runtime.RuntimeData) –
- Return type
None
-
enable
(runtime)¶ Runs the preparation work.
- Parameters
runtime (parsley.runtime.runtime.RuntimeData) –
- Return type
None
-
ensuredisabledafter
()¶ Defines if this preparation is required to be disabled after the synchronization ended. For example, it is an error situation if a certain mountpoint is mounted even after this preparation has unmounted it.
- Return type
bool
-
ensuredisabledbefore
()¶ Defines if this preparation is required to be disabled before the synchronization begins. For example, it is an error situation if a certain mountpoint is already mounted before this preparation has mounted it.
- Return type
bool
-
ensureenabled
()¶ Defines if this preparation is required to be successful for the ongoing process of synchronization. For example, a preparation that just does some uncritical cleanup, should not stop the complete synchronization if it fails.
- Return type
bool
-
getstate
(runtime)¶ Checks if the preparation is successfully done or not. The parsley engine will check the state with this method at certain times and decide what to do depending on the state and the return values of ensuredisabledbefore, ensuredisabledafter and ensureenabled.
- Parameters
runtime (parsley.runtime.runtime.RuntimeData) –
- Return type
bool
-
parsley.preparation.mountpreparation module¶
-
class
parsley.preparation.mountpreparation.
MountPreparation
(*, src, tgt, **kwargs)¶ Bases:
parsley.preparation.abstractpreparation.Preparation
Mounts filesystems to a mountpoint.
- Parameters
src (str) –
tgt (str) –
-
static
_checkmountpointempty
(tgt)¶
-
disable
(runtime)¶ Undo the preparation after the synchronization (like unmounting).
-
enable
(runtime)¶ Runs the preparation work.
-
getstate
(runtime)¶ Checks if the preparation is successfully done or not. The parsley engine will check the state with this method at certain times and decide what to do depending on the state and the return values of ensuredisabledbefore, ensuredisabledafter and ensureenabled.
-
exception
parsley.preparation.mountpreparation.
MountPreparationError
¶
-
exception
parsley.preparation.mountpreparation.
MountpointNotEmptyError
(mountpoint)¶ Bases:
parsley.preparation.mountpreparation.MountPreparationError
- Parameters
mountpoint (str) –
-
exception
parsley.preparation.mountpreparation.
UnableToGetMountListError
(msg)¶ Bases:
parsley.preparation.mountpreparation.MountPreparationError
- Parameters
msg (str) –
-
exception
parsley.preparation.mountpreparation.
UnableToMountError
(mountpoint, msg)¶ Bases:
parsley.preparation.mountpreparation.MountPreparationError
- Parameters
mountpoint (str) –
msg (str) –
-
exception
parsley.preparation.mountpreparation.
UnableToUnmountError
(mountpoint, msg)¶ Bases:
parsley.preparation.mountpreparation.MountPreparationError
- Parameters
mountpoint (str) –
msg (str) –
parsley.preparation.preparator module¶
Helper for enabling and disabling preparations.
-
class
parsley.preparation.preparator.
Preparator
(runtime, preparation)¶ Bases:
object
- Parameters
runtime (parsley.runtime.runtime.RuntimeData) –
preparation (parsley.preparation.abstractpreparation.Preparation) –
-
static
_logandthrowexception
(runtime, exclass, olde=None)¶ - Parameters
runtime (parsley.runtime.runtime.RuntimeData) –
exclass (Type[Exception]) –
olde (Optional[Exception]) –
- Return type
None
parsley.preparation.sshfsmountpreparation module¶
-
class
parsley.preparation.sshfsmountpreparation.
SshfsMountPreparation
(*, src, tgt, idfile=None, password=None, port=22, timeout='10s', **kwargs)¶ Bases:
parsley.preparation.mountpreparation.MountPreparation
Mounts remote filesystems with sshfs.
- Parameters
src (str) –
tgt (str) –
idfile (Optional[str]) –
password (Optional[str]) –
port (int) –
timeout (Union[datetime.timedelta, str]) –
-
disable
(runtime)¶ Undo the preparation after the synchronization (like unmounting).
-
enable
(runtime)¶ Runs the preparation work.
-
static
translate_to_alternative_endpoint
(src, port, runtime)¶ - Parameters
src (str) –
port (int) –
runtime (parsley.runtime.runtime.RuntimeData) –
- Return type
Tuple[str, int]