Client API¶
SpindleX provides high-level SSH and SFTP client implementations for both synchronous and asynchronous use.
SSH Client¶
spindlex.client.ssh_client ¶
SSH Client Implementation
High-level SSH client for establishing connections, executing commands, and managing SSH sessions with comprehensive authentication support.
Classes¶
ChannelFile ¶
File-like object for SSH channel streams.
Provides file-like interface for reading from and writing to SSH channels.
Source code in spindlex/client/ssh_client.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 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 | |
Attributes¶
channel property ¶
Get underlying SSH channel.
Methods:¶
__enter__() ¶
__exit__(exc_type, exc_val, exc_tb) ¶
__init__(channel, mode='r') ¶
Initialize channel file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel | Channel | SSH channel instance | required |
mode | str | File mode ('r' for read, 'w' for write, 'stderr' for stderr) | 'r' |
Source code in spindlex/client/ssh_client.py
__iter__() ¶
Make object iterable for line-by-line reading.
Returns:
| Type | Description |
|---|---|
ChannelFile | Self as iterator |
__next__() ¶
Read next line from channel.
Returns:
| Type | Description |
|---|---|
str | Next line of data |
Raises:
| Type | Description |
|---|---|
StopIteration | If EOF reached |
close() ¶
get_exit_status() ¶
Get command exit status.
Returns:
| Type | Description |
|---|---|
int | Exit status code, or -1 if not available |
read(size=-1) ¶
Read data from channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size | int | Number of bytes to read (-1 for all until EOF) | -1 |
Returns:
| Type | Description |
|---|---|
bytes | Read data |
Source code in spindlex/client/ssh_client.py
readline() ¶
Read a single line from the channel.
Returns:
| Type | Description |
|---|---|
str | Read line |
Source code in spindlex/client/ssh_client.py
recv_exit_status() ¶
Wait for and return command exit status.
Returns:
| Type | Description |
|---|---|
int | Exit status code |
write(data) ¶
Write data to channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data | Union[str, bytes] | Data to write | required |
Returns:
| Type | Description |
|---|---|
int | Number of bytes written |
Source code in spindlex/client/ssh_client.py
SSHClient ¶
High-level SSH client interface.
Provides convenient methods for SSH operations including connection establishment, command execution, shell access, and SFTP operations.
Source code in spindlex/client/ssh_client.py
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 245 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 284 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 347 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 400 401 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 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 | |
Attributes¶
is_active property ¶
Check if SSH connection is active.
username property ¶
Return the username used to authenticate this connection, or None if not connected.
Methods:¶
__enter__() ¶
__exit__(exc_type, exc_val, exc_tb) ¶
__init__() ¶
Initialize SSH client with default settings.
Source code in spindlex/client/ssh_client.py
auth_gssapi(username, gss_host=None, gss_deleg_creds=False) ¶
Authenticate using GSSAPI (Kerberos).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username | str | Username for authentication | required |
gss_host | Optional[str] | GSSAPI hostname (optional) | None |
gss_deleg_creds | bool | Whether to delegate credentials | False |
Raises:
| Type | Description |
|---|---|
AuthenticationException | If authentication fails |
Source code in spindlex/client/ssh_client.py
auth_keyboard_interactive(username, handler=None) ¶
Authenticate using keyboard-interactive method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username | str | Username for authentication | required |
handler | Optional[Callable[[str, str, list[tuple[str, bool]]], list[str]]] | Callback function to handle prompts. If None, uses console_handler (terminal prompts). | None |
Raises:
| Type | Description |
|---|---|
AuthenticationException | If authentication fails |
Source code in spindlex/client/ssh_client.py
auth_password(username, password) ¶
Authenticate using password.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username | str | Username for authentication | required |
password | str | Password for authentication | required |
Raises:
| Type | Description |
|---|---|
AuthenticationException | If authentication fails |
Source code in spindlex/client/ssh_client.py
auth_publickey(username, pkey=None, key_filename=None, password=None) ¶
Authenticate using public key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username | str | Username for authentication | required |
pkey | Optional[PKey] | Private key instance | None |
key_filename | Optional[str] | Path to private key file | None |
password | Optional[str] | Optional password for encrypted private keys | None |
Raises:
| Type | Description |
|---|---|
AuthenticationException | If authentication fails |
Source code in spindlex/client/ssh_client.py
close() ¶
Close SSH connection and cleanup resources.
Source code in spindlex/client/ssh_client.py
close_port_forward(tunnel_id) ¶
Close port forwarding tunnel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tunnel_id | str | Tunnel identifier returned by create_*_port_forward | required |
Raises:
| Type | Description |
|---|---|
SSHException | If tunnel closure fails |
Source code in spindlex/client/ssh_client.py
connect(hostname, port=22, username=None, password=None, pkey=None, key_filename=None, key_password=None, timeout=None, compress=False, sock=None, gss_auth=False, gss_kex=False, gss_deleg_creds=True, gss_host=None, rekey_bytes_limit=None, rekey_time_limit=None) ¶
Connect to SSH server and authenticate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hostname | str | Server hostname or IP address | required |
port | int | Server port (default 22) | 22 |
username | Optional[str] | Username for authentication | None |
password | Optional[str] | Password for authentication | None |
pkey | Optional[PKey] | Private key for authentication | None |
key_filename | Optional[str] | Path to private key file | None |
timeout | Optional[float] | Connection timeout in seconds | None |
compress | bool | Whether to enable compression | False |
sock | Optional[socket] | Optional existing socket to use | None |
gss_auth | bool | Whether to use GSSAPI authentication | False |
gss_kex | bool | Whether to use GSSAPI key exchange | False |
gss_deleg_creds | bool | Whether to delegate GSSAPI credentials | True |
gss_host | Optional[str] | GSSAPI hostname override | None |
rekey_bytes_limit | Optional[int] | Number of bytes before rekeying (default: 1GB) | None |
rekey_time_limit | Optional[float] | Seconds before rekeying (default: 1 hour) | None |
Raises:
| Type | Description |
|---|---|
SSHException | If connection or authentication fails |
Source code in spindlex/client/ssh_client.py
284 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 347 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 400 401 402 403 404 | |
create_local_port_forward(local_port, remote_host, remote_port, local_host='127.0.0.1') ¶
Create local port forwarding tunnel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_port | int | Local port to listen on | required |
remote_host | str | Remote host to connect to | required |
remote_port | int | Remote port to connect to | required |
local_host | str | Local interface to bind to | '127.0.0.1' |
Returns:
| Type | Description |
|---|---|
str | Tunnel ID for management |
Raises:
| Type | Description |
|---|---|
SSHException | If tunnel creation fails |
Source code in spindlex/client/ssh_client.py
create_remote_port_forward(remote_port, local_host, local_port, remote_host='') ¶
Create remote port forwarding tunnel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
remote_port | int | Remote port to listen on | required |
local_host | str | Local host to connect to | required |
local_port | int | Local port to connect to | required |
remote_host | str | Remote interface to bind to | '' |
Returns:
| Type | Description |
|---|---|
str | Tunnel ID for management |
Raises:
| Type | Description |
|---|---|
SSHException | If tunnel creation fails |
Source code in spindlex/client/ssh_client.py
exec_command(command, bufsize=-1) ¶
Execute command on remote server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command | str | Command to execute | required |
bufsize | int | Buffer size for streams (unused, kept for compatibility) | -1 |
Returns:
| Type | Description |
|---|---|
tuple[ChannelFile, ChannelFile, ChannelFile] | Tuple of (stdin, stdout, stderr) file-like objects |
Raises:
| Type | Description |
|---|---|
SSHException | If command execution fails |
Source code in spindlex/client/ssh_client.py
get_host_key_storage() ¶
get_host_keys() ¶
get_port_forwards() ¶
Get all active port forwarding tunnels.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | Dictionary of tunnel ID to tunnel information |
Raises:
| Type | Description |
|---|---|
SSHException | If operation fails |
Source code in spindlex/client/ssh_client.py
get_transport() ¶
Get underlying transport object.
Returns:
| Type | Description |
|---|---|
Optional[Transport] | Transport instance or None if not connected |
invoke_shell() ¶
Start interactive shell session.
Returns:
| Type | Description |
|---|---|
Channel | Channel object for shell interaction |
Raises:
| Type | Description |
|---|---|
SSHException | If shell invocation fails |
Source code in spindlex/client/ssh_client.py
is_connected() ¶
Check if client is connected and authenticated.
Returns:
| Type | Description |
|---|---|
bool | True if connected and authenticated, False otherwise |
Source code in spindlex/client/ssh_client.py
load_host_keys(filename) ¶
Load host keys from a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename | str | Path to known_hosts file | required |
Source code in spindlex/client/ssh_client.py
load_system_host_keys() ¶
Load host keys from system default locations.
Source code in spindlex/client/ssh_client.py
open_sftp() ¶
Open SFTP session.
Returns:
| Type | Description |
|---|---|
SFTPClient | SFTPClient instance for file operations |
Raises:
| Type | Description |
|---|---|
SSHException | If SFTP session creation fails |
Source code in spindlex/client/ssh_client.py
save_host_keys(filename) ¶
Save host keys to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename | str | Path to save known_hosts | required |
Source code in spindlex/client/ssh_client.py
set_host_key_storage(storage) ¶
Set host key storage instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
storage | HostKeyStorage | Host key storage to use | required |
set_missing_host_key_policy(policy) ¶
Set policy for handling unknown host keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy | MissingHostKeyPolicy | Host key policy to use for unknown hosts | required |
Functions:¶
spindlex.client.async_ssh_client ¶
Async SSH Client Implementation
Provides asynchronous SSH client functionality for high-concurrency applications.
Classes¶
AsyncSSHClient ¶
Async SSH client for establishing SSH connections and executing commands.
Provides asynchronous versions of all SSH client operations for use in async/await applications and high-concurrency scenarios.
Source code in spindlex/client/async_ssh_client.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 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 245 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 284 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 347 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 400 401 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 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
Attributes¶
connected property ¶
Check if client is connected.
hostname property ¶
Get connected hostname.
port property ¶
Get connected port.
username property ¶
Get authenticated username.
Methods:¶
__aenter__() async ¶
__aexit__(exc_type, exc_val, exc_tb) async ¶
__init__() ¶
Initialize async SSH client.
Source code in spindlex/client/async_ssh_client.py
auth_gssapi(username, gss_host=None, gss_deleg_creds=False) async ¶
Authenticate using GSSAPI (Kerberos) asynchronously.
Source code in spindlex/client/async_ssh_client.py
auth_keyboard_interactive(username, handler=None) async ¶
Authenticate using keyboard-interactive method asynchronously.
Source code in spindlex/client/async_ssh_client.py
auth_password(username, password) async ¶
Authenticate using password asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username | str | Username for authentication | required |
password | str | Password for authentication | required |
Raises:
| Type | Description |
|---|---|
AuthenticationException | If authentication fails |
Source code in spindlex/client/async_ssh_client.py
auth_publickey(username, pkey=None, key_filename=None, password=None) async ¶
Authenticate using public key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username | str | Username for authentication | required |
pkey | Any | None | Private key instance | None |
key_filename | str | list[str] | None | Path to private key file(s) | None |
password | str | None | Optional password for encrypted private keys | None |
Raises:
| Type | Description |
|---|---|
AuthenticationException | If authentication fails |
Source code in spindlex/client/async_ssh_client.py
close() async ¶
Close SSH connection and cleanup resources.
Source code in spindlex/client/async_ssh_client.py
close_port_forward(tunnel_id) async ¶
Close port forwarding tunnel asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tunnel_id | str | Tunnel identifier | required |
Source code in spindlex/client/async_ssh_client.py
connect(hostname, port=22, username=None, password=None, pkey=None, key_filename=None, key_password=None, timeout=None, compress=False, sock=None, gss_auth=False, gss_kex=False, gss_deleg_creds=True, gss_host=None, rekey_bytes_limit=None, rekey_time_limit=None) async ¶
Connect to SSH server asynchronously with retry logic for transient errors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hostname | str | Server hostname or IP address | required |
port | int | Server port (default: 22) | 22 |
username | str | None | Username for authentication | None |
password | str | None | Password for authentication | None |
pkey | Any | None | Private key for authentication | None |
key_filename | str | list[str] | None | Path to private key file(s) | None |
key_password | str | None | Password for encrypted private key file(s) | None |
timeout | float | None | Connection timeout in seconds | None |
compress | bool | Enable compression | False |
sock | Any | None | Optional existing socket or channel to use | None |
rekey_bytes_limit | int | None | Number of bytes before rekeying (default: 1GB) | None |
rekey_time_limit | int | None | Seconds before rekeying (default: 1 hour) | None |
gss_auth | bool | Use GSSAPI authentication | False |
gss_kex | bool | Use GSSAPI key exchange | False |
gss_deleg_creds | bool | Delegate GSSAPI credentials | True |
gss_host | str | None | GSSAPI hostname override | None |
Raises:
| Type | Description |
|---|---|
SSHException | If connection fails |
AuthenticationException | If authentication fails |
Source code in spindlex/client/async_ssh_client.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 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 | |
create_local_port_forward(local_port, remote_host, remote_port, local_host='127.0.0.1') async ¶
Create local port forwarding tunnel asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_port | int | Local port to listen on | required |
remote_host | str | Remote host to connect to | required |
remote_port | int | Remote port to connect to | required |
local_host | str | Local interface to bind to | '127.0.0.1' |
Returns:
| Type | Description |
|---|---|
str | Tunnel ID for management |
Source code in spindlex/client/async_ssh_client.py
create_remote_port_forward(remote_port, local_host, local_port, remote_host='') async ¶
Create remote port forwarding tunnel asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
remote_port | int | Remote port to listen on | required |
local_host | str | Local host to connect to | required |
local_port | int | Local port to connect to | required |
remote_host | str | Remote interface to bind to | '' |
Returns:
| Type | Description |
|---|---|
str | Tunnel ID for management |
Source code in spindlex/client/async_ssh_client.py
exec_command(command, bufsize=-1, timeout=None) async ¶
Execute command on remote server asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command | str | Command to execute | required |
bufsize | int | Buffer size for streams | -1 |
timeout | float | None | Command timeout in seconds | None |
Returns:
| Type | Description |
|---|---|
tuple[Any, Any, Any] | Tuple of (stdin, stdout, stderr) streams |
Raises:
| Type | Description |
|---|---|
SSHException | If command execution fails |
Source code in spindlex/client/async_ssh_client.py
get_host_key_storage() ¶
get_host_keys() ¶
get_port_forwards() ¶
Get all active port forwarding tunnels.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | Dictionary mapping tunnel IDs to tunnel objects |
Source code in spindlex/client/async_ssh_client.py
invoke_shell() async ¶
Start interactive shell asynchronously.
Returns:
| Type | Description |
|---|---|
Any | Channel for shell interaction |
Raises:
| Type | Description |
|---|---|
SSHException | If shell invocation fails |
Source code in spindlex/client/async_ssh_client.py
load_host_keys(filename) async ¶
Load host keys from a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename | str | Path to known_hosts file | required |
Source code in spindlex/client/async_ssh_client.py
load_system_host_keys() async ¶
Load host keys from system default locations.
Source code in spindlex/client/async_ssh_client.py
open_sftp() async ¶
Open SFTP client asynchronously.
Returns:
| Type | Description |
|---|---|
AsyncSFTPClient | Async SFTP client instance |
Raises:
| Type | Description |
|---|---|
SSHException | If SFTP open fails |
Source code in spindlex/client/async_ssh_client.py
save_host_keys(filename) async ¶
Save host keys to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename | str | Path to save known_hosts | required |
Source code in spindlex/client/async_ssh_client.py
set_host_key_storage(storage) ¶
Set host key storage instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
storage | HostKeyStorage | Host key storage to use | required |
set_missing_host_key_policy(policy) ¶
Set policy for handling unknown host keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy | MissingHostKeyPolicy | Host key policy instance | required |
SFTP Client¶
spindlex.client.sftp_client ¶
SFTP Client Implementation
Provides SFTP (SSH File Transfer Protocol) client functionality for secure file operations over SSH connections.
Classes¶
SFTPClient ¶
SFTP client for secure file operations.
Implements SFTP protocol for file transfer, directory operations, and file attribute management over SSH connections.
Source code in spindlex/client/sftp_client.py
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 245 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 284 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 347 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 400 401 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 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 | |
Methods:¶
__enter__() ¶
__exit__(exc_type, exc_val, exc_tb) ¶
__init__(transport) ¶
Initialize SFTP client with SSH transport.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transport | Transport | SSH transport instance | required |
Raises:
| Type | Description |
|---|---|
SFTPError | If SFTP initialization fails |
Source code in spindlex/client/sftp_client.py
chmod(path, mode) ¶
Change file permissions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path to file | required |
mode | int | New permission mode | required |
Raises:
| Type | Description |
|---|---|
SFTPError | If chmod operation fails |
Source code in spindlex/client/sftp_client.py
close() ¶
Close SFTP session and cleanup resources.
Source code in spindlex/client/sftp_client.py
get(remotepath, localpath) ¶
Download file from remote server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
remotepath | str | Path to remote file | required |
localpath | str | Path for local file | required |
Raises:
| Type | Description |
|---|---|
SFTPError | If file download fails |
Source code in spindlex/client/sftp_client.py
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 | |
get_recursive(remotepath, localpath) ¶
Download directory recursively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
remotepath | str | Remote directory path | required |
localpath | str | Local destination path | required |
Source code in spindlex/client/sftp_client.py
getcwd() ¶
Get current working directory.
Returns:
| Type | Description |
|---|---|
str | Current working directory path |
Raises:
| Type | Description |
|---|---|
SFTPError | If operation fails |
Source code in spindlex/client/sftp_client.py
listdir(path='.') ¶
List directory contents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Directory path to list | '.' |
Returns:
| Type | Description |
|---|---|
list[str] | List of filenames in directory |
Raises:
| Type | Description |
|---|---|
SFTPError | If directory listing fails |
Source code in spindlex/client/sftp_client.py
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 | |
lstat(path) ¶
Get file/directory attributes (don't follow symlinks).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path to file or directory | required |
Returns:
| Type | Description |
|---|---|
SFTPAttributes | SFTPAttributes object with file information |
Raises:
| Type | Description |
|---|---|
SFTPError | If lstat operation fails |
Source code in spindlex/client/sftp_client.py
mkdir(path, mode=511) ¶
Create directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Directory path to create | required |
mode | int | Directory permissions | 511 |
Raises:
| Type | Description |
|---|---|
SFTPError | If directory creation fails |
Source code in spindlex/client/sftp_client.py
normalize(path) ¶
Normalize path (resolve . and .. components).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path to normalize | required |
Returns:
| Type | Description |
|---|---|
str | Normalized path |
Raises:
| Type | Description |
|---|---|
SFTPError | If operation fails |
Source code in spindlex/client/sftp_client.py
open(filename, mode='r') ¶
Open remote file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename | str | Remote file path | required |
mode | str | File open mode (r, w, a, rb, wb, ab) | 'r' |
Returns:
| Type | Description |
|---|---|
SFTPFile | SFTPFile object |
Raises:
| Type | Description |
|---|---|
SFTPError | If file open fails |
Source code in spindlex/client/sftp_client.py
put(localpath, remotepath) ¶
Upload file to remote server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
localpath | str | Path to local file | required |
remotepath | str | Path for remote file | required |
Raises:
| Type | Description |
|---|---|
SFTPError | If file upload fails |
Source code in spindlex/client/sftp_client.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 | |
put_recursive(localpath, remotepath) ¶
Upload directory recursively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
localpath | str | Local directory path | required |
remotepath | str | Remote destination path | required |
Source code in spindlex/client/sftp_client.py
readlink(path) ¶
Read symbolic link.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path to symbolic link | required |
Returns:
| Type | Description |
|---|---|
str | Target path of the link |
Raises:
| Type | Description |
|---|---|
SFTPError | If operation fails |
Source code in spindlex/client/sftp_client.py
remove(path) ¶
Remove file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | File path to remove | required |
Raises:
| Type | Description |
|---|---|
SFTPError | If file removal fails |
Source code in spindlex/client/sftp_client.py
rename(oldpath, newpath) ¶
Rename file or directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
oldpath | str | Current path | required |
newpath | str | New path | required |
Raises:
| Type | Description |
|---|---|
SFTPError | If rename operation fails |
Source code in spindlex/client/sftp_client.py
rmdir(path) ¶
Remove directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Directory path to remove | required |
Raises:
| Type | Description |
|---|---|
SFTPError | If directory removal fails |
Source code in spindlex/client/sftp_client.py
stat(path) ¶
Get file/directory attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path to file or directory | required |
Returns:
| Type | Description |
|---|---|
SFTPAttributes | SFTPAttributes object with file information |
Raises:
| Type | Description |
|---|---|
SFTPError | If stat operation fails |
Source code in spindlex/client/sftp_client.py
symlink(targetpath, linkpath) ¶
Create symbolic link.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
targetpath | str | Target path for the link | required |
linkpath | str | Path where link should be created | required |
Raises:
| Type | Description |
|---|---|
SFTPError | If symlink creation fails |
Source code in spindlex/client/sftp_client.py
SFTPFile ¶
SFTP file object for remote file operations.
Source code in spindlex/client/sftp_client.py
53 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 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 | |
Methods:¶
__enter__() ¶
__exit__(exc_type, exc_val, exc_tb) ¶
__init__(client, handle, mode) ¶
Initialize SFTP file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client | SFTPClient | SFTP client instance | required |
handle | bytes | File handle from server | required |
mode | str | File open mode | required |
Source code in spindlex/client/sftp_client.py
close() ¶
Close remote file.
Source code in spindlex/client/sftp_client.py
read(size=-1) ¶
Read data from remote file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size | int | Number of bytes to read (-1 for all) | -1 |
Returns:
| Type | Description |
|---|---|
bytes | Read data |
Source code in spindlex/client/sftp_client.py
write(data) ¶
Write data to remote file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data | bytes | Data to write | required |
Returns:
| Type | Description |
|---|---|
int | Number of bytes written |
Source code in spindlex/client/sftp_client.py
spindlex.client.async_sftp_client ¶
Async SFTP Client Implementation
Provides asynchronous SFTP client functionality for file operations.
Classes¶
AsyncSFTPClient ¶
Async SFTP client for file transfer operations.
Provides asynchronous versions of all SFTP operations for use in async/await applications and high-concurrency scenarios.
Source code in spindlex/client/async_sftp_client.py
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 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 245 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 284 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 347 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 400 401 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 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 | |
Methods:¶
__aenter__() async ¶
__aexit__(exc_type, exc_val, exc_tb) async ¶
__init__(channel) ¶
Initialize async SFTP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel | Any | SSH channel for SFTP subsystem | required |
Source code in spindlex/client/async_sftp_client.py
chmod(path, mode) async ¶
Change remote file permissions.
Source code in spindlex/client/async_sftp_client.py
close() async ¶
Close SFTP client and cleanup resources.
Source code in spindlex/client/async_sftp_client.py
get(remotepath, localpath) async ¶
Download file from remote server asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
remotepath | str | Remote file path | required |
localpath | str | Local file path | required |
Raises:
| Type | Description |
|---|---|
SFTPError | If download fails |
Source code in spindlex/client/async_sftp_client.py
get_recursive(remotepath, localpath) async ¶
Download directory recursively and asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
remotepath | str | Remote directory path | required |
localpath | str | Local destination path | required |
Source code in spindlex/client/async_sftp_client.py
listdir(path='.') async ¶
List directory contents asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Directory path to list | '.' |
Returns:
| Type | Description |
|---|---|
list[str] | List of filenames in directory |
Raises:
| Type | Description |
|---|---|
SFTPError | If listing fails |
Source code in spindlex/client/async_sftp_client.py
lstat(path) async ¶
Get file/directory attributes (without following symlinks) asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | File or directory path | required |
Returns:
| Type | Description |
|---|---|
Any | File attributes |
Raises:
| Type | Description |
|---|---|
SFTPError | If lstat fails |
Source code in spindlex/client/async_sftp_client.py
mkdir(path, mode=493) async ¶
Create directory asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Directory path to create | required |
mode | int | Directory permissions | 493 |
Raises:
| Type | Description |
|---|---|
SFTPError | If mkdir fails |
Source code in spindlex/client/async_sftp_client.py
normalize(path) async ¶
Resolve remote path to its absolute canonical form.
Source code in spindlex/client/async_sftp_client.py
open(filename, mode='r') async ¶
Open remote file asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename | str | Remote file path | required |
mode | str | File open mode | 'r' |
Returns:
| Type | Description |
|---|---|
AsyncSFTPFile | Async SFTP file object |
Raises:
| Type | Description |
|---|---|
SFTPError | If file open fails |
Source code in spindlex/client/async_sftp_client.py
put(localpath, remotepath) async ¶
Upload file to remote server asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
localpath | str | Local file path | required |
remotepath | str | Remote file path | required |
Raises:
| Type | Description |
|---|---|
SFTPError | If upload fails |
Source code in spindlex/client/async_sftp_client.py
put_recursive(localpath, remotepath) async ¶
Upload directory recursively and asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
localpath | str | Local directory path | required |
remotepath | str | Remote destination path | required |
Source code in spindlex/client/async_sftp_client.py
readlink(path) async ¶
Read symbolic link asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path to symbolic link | required |
Returns:
| Type | Description |
|---|---|
str | Target path of the link |
Raises:
| Type | Description |
|---|---|
SFTPError | If readlink fails |
Source code in spindlex/client/async_sftp_client.py
remove(path) async ¶
Remove remote file asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Remote file path to remove | required |
Raises:
| Type | Description |
|---|---|
SFTPError | If removal fails |
Source code in spindlex/client/async_sftp_client.py
rename(oldpath, newpath) async ¶
Rename remote file or directory.
Source code in spindlex/client/async_sftp_client.py
rmdir(path) async ¶
Remove directory asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Directory path to remove | required |
Raises:
| Type | Description |
|---|---|
SFTPError | If rmdir fails |
Source code in spindlex/client/async_sftp_client.py
stat(path) async ¶
Get file/directory attributes asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | File or directory path | required |
Returns:
| Type | Description |
|---|---|
Any | File attributes |
Raises:
| Type | Description |
|---|---|
SFTPError | If stat fails |
Source code in spindlex/client/async_sftp_client.py
symlink(targetpath, linkpath) async ¶
Create symbolic link asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
targetpath | str | Target path for the link | required |
linkpath | str | Path where link should be created | required |
Raises:
| Type | Description |
|---|---|
SFTPError | If symlink fails |
Source code in spindlex/client/async_sftp_client.py
AsyncSFTPFile ¶
Async SFTP file object for remote file operations.
Source code in spindlex/client/async_sftp_client.py
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 | |
Methods:¶
__aenter__() async ¶
__aexit__(exc_type, exc_val, exc_tb) async ¶
__init__(client, handle, mode) ¶
Initialize async SFTP file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client | AsyncSFTPClient | SFTP client instance | required |
handle | bytes | File handle from server | required |
mode | str | File open mode | required |
Source code in spindlex/client/async_sftp_client.py
close() async ¶
Close file handle.
Source code in spindlex/client/async_sftp_client.py
read(size=-1) async ¶
Read data from file asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size | int | Number of bytes to read (-1 for all) | -1 |
Returns:
| Type | Description |
|---|---|
bytes | Read data |
Raises:
| Type | Description |
|---|---|
SFTPError | If read fails |
Source code in spindlex/client/async_sftp_client.py
935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 | |
write(data) async ¶
Write data to file asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data | bytes | Data to write | required |
Raises:
| Type | Description |
|---|---|
SFTPError | If write fails |