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, 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.
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
|
The source root directory to copy from |
required |
settings
|
RobocopySettings
|
RobocopySettings containing destination and options |
required |
Example
settings = RobocopySettings(
destination="D:/destination",
exclude_dirs=["__pycache__", ".git"],
exclude_files=["*.pyc"],
)
service = RobocopyService("C:/source", settings)
Source code in src/clabe/data_transfer/robocopy.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 | |
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
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
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
146 147 148 149 150 151 152 153 154 155 156 | |
run ¶
run(
executor_kwargs: Optional[dict[str, Any]] = None,
) -> CommandResult
Execute the command using a local executor and return the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
executor_kwargs
|
Optional[dict[str, Any]]
|
Keyword arguments forwarded to the local executor. |
None
|
Source code in src/clabe/apps/_executors.py
288 289 290 291 292 293 294 295 | |
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
executor_kwargs
|
Optional[dict[str, Any]]
|
Keyword arguments forwarded to the local executor. |
None
|
Source code in src/clabe/apps/_executors.py
297 298 299 300 301 302 303 304 | |