blueye.sdk.logs
logs
Classes:
-
LegacyLogFile
–This class is a container for a log file stored on the drone
-
LegacyLogs
–This class is an index of the legacy csv log files stored on the drone
-
LogFile
– -
LogStream
–Class for streaming a log
-
Logs
–
Functions:
-
decompress_log
–Decompress a log file
-
human_readable_filesize
–Convert bytes to human readable string
LegacyLogFile
LegacyLogFile(maxdepth, name, timestamp, binsize, ip)
This class is a container for a log file stored on the drone
The drone lists the file name, max depth, start time, and file size for each log,
and you can show this information by printing the log object, eg. on a Drone
object called myDrone
:
print(myDrone.logs[0])
or, if you want to display the header you can format the object with with_header
:
print(f"{myDrone.logs[0]:with_header}")
Calling the download() method on a log object will pull the CSV (Comma Separated Value) file from the drone to your local filesystem.
Methods:
-
download
–Download the specified log to your local file system
Source code in blueye/sdk/logs.py
304 305 306 307 308 309 310 311 312 313 314 315 |
|
download
download(
output_path=None,
output_name=None,
downsample_divisor=10,
)
Download the specified log to your local file system
If you specify an output_path the log file will be downloaded to that directory instead of the current one.
Specifying output_name will overwrite the default file name with whatever you have specified (be sure to include the .csv extension).
The drone samples the log content at 10 Hz, and by default this function downsamples this rate to 1 Hz.
Source code in blueye/sdk/logs.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
|
LegacyLogs
LegacyLogs(parent_drone, auto_download_index=False)
This class is an index of the legacy csv log files stored on the drone
To show the available logs you simply print this object, ie. if your Drone object
is called myDrone
, you can do:
print(myDrone.legacy_logs)
This will print a list of all available logs, with some of their metadata, such as name and maxdepth.
You can access logfile objects either by index or by name. Eg. if you want the first
logfile in the list you can do myDrone.logs[0]
, or if you want some particular log you
can do myDrone.logs["exampleName0001.csv"]
. You can even give it a slice, so if you want
the last 10 logs you can do myDrone.logs[-10:]
.
Methods:
-
refresh_log_index
–Refresh the log index from the drone
Source code in blueye/sdk/logs.py
372 373 374 375 376 377 378 379 |
|
refresh_log_index
refresh_log_index(get_all_logs=False)
Refresh the log index from the drone
This is method is run on the first log access by default, but if you would like to check for new log files it can be called at any time.
Pass with get_all_logs=True
to include logs that are not classified as dives.
Source code in blueye/sdk/logs.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
|
LogFile
LogFile(
name: str,
is_dive: bool,
filesize: int,
start_time: int,
max_depth_magnitude: int,
ip: str,
)
Methods:
-
download
–Download a log file from the drone
-
parse_to_stream
–Parse the log file to a stream
Source code in blueye/sdk/logs.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
download
download(
output_path: Optional[Path | str] = None,
write_to_file: bool = True,
timeout: float = 1,
overwrite_cache: bool = False,
) -> bytes
Download a log file from the drone
Arguments:
output_path
: Path to write the log file to. IfNone
, the log will be written to the current working directory. If the path is a directory, the log will be downloaded to that directory with its original name. Else the log will be downloaded to the specified path.write_to_file
: If True, the log will be written to the specified path. If False, the log will only be returned as a bytes object.timeout
: Seconds to wait for responseoverwrite_cache
: If True, the log will be downloaded even if it is already been downloaded.
Returns:
The compressed log file as a bytes object.
Source code in blueye/sdk/logs.py
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 |
|
parse_to_stream
parse_to_stream() -> LogStream
Parse the log file to a stream
Will download the log if it is not already downloaded.
Returns:
A LogStream
object
Source code in blueye/sdk/logs.py
151 152 153 154 155 156 157 158 159 160 |
|
LogStream
LogStream(log: bytes, decompress: bool = True)
Class for streaming a log
Creates a stream from a downloaded log file. Iterate over the object to get the next log record.
Source code in blueye/sdk/logs.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
Logs
Logs(parent_drone, auto_download_index=False)
Methods:
-
filter
–Return a new Logs object with only those matching the filter
-
refresh_log_index
–Refresh the log index from the drone
Source code in blueye/sdk/logs.py
178 179 180 181 182 183 184 |
|
filter
Return a new Logs object with only those matching the filter
Eg. to get logs classified as a dive:
dive_logs = myDrone.logs.filter(lambda log: log.is_dive)
or to get all logs with a max depth greater than 10m:
deep_logs = myDrone.logs.filter(lambda log: log.max_depth_magnitude > 10)
Source code in blueye/sdk/logs.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
refresh_log_index
refresh_log_index()
Refresh the log index from the drone
This is method is run on the first log access by default, but if you would like to check for new log files it can be called at any time.
Source code in blueye/sdk/logs.py
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 |
|
decompress_log
decompress_log(log: bytes) -> bytes
Decompress a log file
Source code in blueye/sdk/logs.py
33 34 35 |
|
human_readable_filesize
human_readable_filesize(binsize: int) -> str
Convert bytes to human readable string
Source code in blueye/sdk/logs.py
22 23 24 25 26 27 28 29 30 |
|