data_transfer.robocopy¶
RobocopySettings ¶
Bases: ServiceSettings
Settings for the RobocopyService.
Configuration for Robocopy file transfer including destination, logging, and copy options.
settings_customise_sources
classmethod
¶
settings_customise_sources(
settings_cls: Type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> Tuple[PydanticBaseSettingsSource, ...]
Customizes the settings sources to include the safe YAML settings source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings_cls
|
Type[BaseSettings]
|
The settings class |
required |
init_settings
|
PydanticBaseSettingsSource
|
The initial settings source |
required |
env_settings
|
PydanticBaseSettingsSource
|
The environment settings source |
required |
dotenv_settings
|
PydanticBaseSettingsSource
|
The dotenv settings source |
required |
file_secret_settings
|
PydanticBaseSettingsSource
|
The file secret settings source |
required |
Returns:
| Type | Description |
|---|---|
Tuple[PydanticBaseSettingsSource, ...]
|
Tuple[PydanticBaseSettingsSource, ...]: A tuple of settings sources |
Source code in src/clabe/services.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
RobocopyService ¶
RobocopyService(
source: PathLike | Dict[PathLike, PathLike],
settings: RobocopySettings,
)
Bases: DataTransfer[RobocopySettings], _DefaultExecutorMixin, ExecutableApp
A data transfer service that uses Robocopy to copy files between directories.
Provides a wrapper around the Windows Robocopy utility with configurable options for file copying, logging, and directory management. Supports both single source-destination pairs and multiple mappings via a dictionary.
Attributes:
| Name | Type | Description |
|---|---|---|
command |
Command[CommandResult]
|
The robocopy command to be executed |
Methods:
| Name | Description |
|---|---|
transfer |
Executes the Robocopy file transfer |
validate |
Validates the Robocopy service configuration |
Initializes the RobocopyService.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
PathLike | Dict[PathLike, PathLike]
|
The source directory/file to copy, or a dict mapping sources to destinations |
required |
settings
|
RobocopySettings
|
RobocopySettings containing options |
required |
Example
# Single source-destination:
settings = RobocopySettings(destination="D:/destination")
service = RobocopyService("C:/source", settings)
# Multiple source-destination mappings:
service = RobocopyService({
"C:/data1": "D:/backup1",
"C:/data2": "D:/backup2",
}, settings)
Source code in src/clabe/data_transfer/robocopy.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
settings
property
¶
settings: TSettings
Returns the settings for the data transfer service.
Returns:
| Name | Type | Description |
|---|---|---|
TSettings |
TSettings
|
The service settings |
transfer ¶
transfer() -> None
Executes the data transfer using Robocopy.
Uses the command executor pattern to run robocopy with configured settings.
Example
settings = RobocopySettings(destination="D:/backup")
service = RobocopyService("C:/data", settings)
service.transfer()
Source code in src/clabe/data_transfer/robocopy.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
validate ¶
validate() -> bool
Validates whether the Robocopy command is available on the system.
Returns:
| Type | Description |
|---|---|
bool
|
True if Robocopy is available, False otherwise |
Source code in src/clabe/data_transfer/robocopy.py
147 148 149 150 151 152 153 154 155 156 157 | |
run ¶
run(
executor_kwargs: Optional[dict[str, Any]] = None,
) -> CommandResult
Execute the command using a local executor and return the result.
Source code in src/clabe/apps/_executors.py
280 281 282 283 | |
run_async
async
¶
run_async(
executor_kwargs: Optional[dict[str, Any]] = None,
) -> CommandResult
Execute the command asynchronously using a local executor and return the result.
Source code in src/clabe/apps/_executors.py
285 286 287 288 | |