Download Management
download ¶
ObjectDownloader class to manage file downloads with an option to use rich interface.
This class provides methods to download files from URLs with progress tracking using either tqdm or rich interface. It supports both raw downloads and enhanced visual feedback during the download process.
Functions:
Name | Description |
---|---|
download_file |
Downloads a file from the given URL to the specified path with optional rich interface. |
_download_file_raw |
Static method that performs the actual file download with tqdm progress bar. |
Attributes:
Name | Type | Description |
---|---|---|
None |
|
Example
>>> downloader = ObjectDownloader()
>>> result = downloader.download_file(
... url='http://example.com/file.zip',
... file_path='/downloads',
... filename='file.zip',
... rich_interface=True
... )
SoftManager ¶
SoftManager(dry_run: bool = False)
SoftManager helps to download files from a remote location.
This class provides methods to download files using either a simple progress bar or a rich interface with enhanced visual feedback.
Examples:
>>> downloader = SoftManager()
>>> downloader.download_file(
... url="http://example.com/file.txt",
... file_path="/tmp",
... filename="file.txt"
... )
'/tmp/file.txt'
Source code in eos_downloader/logics/download.py
65 66 67 68 69 70 71 |
|
checksum ¶
checksum(
check_type: Literal["md5sum", "sha512sum", "md5"]
) -> bool
Verifies the integrity of a downloaded file using a specified checksum algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
check_type
|
Literal['md5sum', 'sha512sum', 'md5']
|
The type of checksum to perform. Currently supports ‘md5sum’ or ‘sha512sum’. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the checksum verification passes. |
Raises:
Type | Description |
---|---|
ValueError
|
If the calculated checksum does not match the expected checksum. |
FileNotFoundError
|
If either the checksum file or the target file cannot be found. |
Examples:
>>> client.checksum('sha512sum') # Returns True if checksum matches
Source code in eos_downloader/logics/download.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
|
download_file ¶
download_file(
url: str,
file_path: str,
filename: str,
rich_interface: bool = True,
) -> Union[None, str]
Downloads a file from a given URL to a specified location.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL from which to download the file. |
required |
file_path
|
str
|
The directory path where the file should be saved. |
required |
filename
|
str
|
The name to be given to the downloaded file. |
required |
rich_interface
|
bool
|
Whether to use rich progress bar interface. Defaults to True. |
True
|
Returns:
Type | Description |
---|---|
Union[None, str]
|
The full path to the downloaded file if successful, None if download fails. |
Source code in eos_downloader/logics/download.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
downloads ¶
downloads(
object_arista: eos_downloader.logics.arista_xml_server.AristaXmlObjects,
file_path: str,
rich_interface: bool = True,
) -> Union[None, str]
Downloads files from Arista EOS server.
Downloads the EOS image and optional md5/sha512 files based on the provided EOS XML object. Each file is downloaded to the specified path with appropriate filenames.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
object_arista
|
AristaXmlObjects
|
Object containing EOS image and hash file URLs. |
required |
file_path
|
str
|
Directory path where files should be downloaded. |
required |
rich_interface
|
bool
|
Whether to use rich console output. Defaults to True. |
True
|
Returns:
Type | Description |
---|---|
Union[None, str]
|
The file path where files were downloaded, or None if download failed. |
Examples:
>>> client.downloads(eos_obj, "/tmp/downloads")
'/tmp/downloads'
Source code in eos_downloader/logics/download.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
|
import_docker ¶
import_docker(
local_file_path: str,
docker_name: str = "arista/ceos",
docker_tag: str = "latest",
) -> None
Import a local file into a Docker image.
This method imports a local file into Docker with a specified image name and tag. It checks for the existence of both the local file and docker binary before proceeding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
local_file_path
|
str
|
Path to the local file to import. |
required |
docker_name
|
str
|
Name for the Docker image. Defaults to ‘arista/ceos’. |
'arista/ceos'
|
docker_tag
|
str
|
Tag for the Docker image. Defaults to ‘latest’. |
'latest'
|
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If the local file doesn’t exist or docker binary is not found. |
Exception
|
If the docker import operation fails. |
Returns:
Type | Description |
---|---|
None
|
|
Source code in eos_downloader/logics/download.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
provision_eve ¶
provision_eve(
object_arista: eos_downloader.logics.arista_xml_server.EosXmlObject,
noztp: bool = False,
) -> None
Provisions EVE-NG with the specified Arista EOS object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
object_arista
|
EosXmlObject
|
The Arista EOS object containing version, filename, and URLs. |
required |
noztp
|
bool
|
If True, disables ZTP (Zero Touch Provisioning). Defaults to False. |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
If no URLs are found for download or if a URL or filename is None. |
Returns:
Type | Description |
---|---|
None
|
|
Source code in eos_downloader/logics/download.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 |
|