Snirk API Docs :: fs¶
snirk.fs
¶
Snirk API for connecting to and interacting with SNI device filesystems.
SnirkFilesystem
¶
Bases: Snirk
Container and API for connecting to and interacting with SNI devices with access to device filesystem.
Each operation assures that the SNI device has necessary capabilities before attempting to access the device filesystem, raising a SnirkIncapableError exception when the capabilities are missing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_message_length |
int
|
max bytes to transfer in get/put operations |
required |
Source code in snirk/fs.py
16 17 18 19 20 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 | |
get_file
async
¶
get_file(device_file, timeout=30)
Get device file from SNI device filesystem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_file |
str
|
path to device file to read |
required |
timeout |
int
|
seconds until timeout reading file from device |
30
|
Raises:
| Type | Description |
|---|---|
SnirkIncapableError
|
when device does not have GetFile capability |
Source code in snirk/fs.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
make_directory
async
¶
make_directory(device_path, parents=False, timeout=10)
Create missing directories on SNI device filesystem.
If parents is not true, then an exception will propagate from gRPC if device_path cannot be created because it's parent (sub-)directories do not exist. When parents is true, all missing (sub-)directories will be created in the correct order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_path |
str
|
path to create on SNI device |
required |
parents |
bool
|
when True, create any missing parent (sub-)directories for device_path |
False
|
timeout |
int
|
seconds to try creating directories until timeout |
10
|
Raises:
| Type | Description |
|---|---|
SnirkIncapableError
|
when device does not have MakeDirectory capability |
Source code in snirk/fs.py
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 | |
put_file
async
¶
put_file(data, device_path, timeout=30)
Put file bytes at path on SNI device filesystem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data |
bytes
|
bytes to write to device path |
required |
device_path |
str
|
path on device to write local_file bytes |
required |
timeout |
int
|
seconds until timeout writing file to device |
30
|
Raises:
| Type | Description |
|---|---|
SnirkIncapableError
|
when device does not have PutFile capability |
Source code in snirk/fs.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
read_directory
async
¶
read_directory(path, timeout=2)
Read directory from SNI device filesystem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path |
str
|
directory path to read from device |
required |
timeout |
int
|
seconds until timeout reading directory from device |
2
|
Raises:
| Type | Description |
|---|---|
SnirkIncapableError
|
when device does not have ReadDirectory capability |
Source code in snirk/fs.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
remove_file
async
¶
remove_file(device_file, timeout=5)
Remove device file from SNI device filesystem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_file |
str
|
path to device file to remove |
required |
timeout |
int
|
seconds until timeout removing file from device |
5
|
Raises:
| Type | Description |
|---|---|
SnirkIncapableError
|
when device does not have RemoveFile capability |
Source code in snirk/fs.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |