milestonexprotectwspython.xpwjpegdata

Module: xpwjpegdata.py

Revision History

Date Version Description
2023/07/11 1.0.0.0 Initial Version.

@export
class XPWJpegData:

JPEG data returned by a RecorderCommandService JPEGGetLive call.

Threadsafety:

This class is fully thread-safe.

XPWJpegData()

Initializes a new instance of the class.

Data: bytes

JPEG data, represented as raw bytes.

Returns:

The Data property value.

DataEncoded: str

JPEG data, represented as a base64 ASCII encoded string.

Returns:

The Data property value.

HasData: bool

True if the Data property contains valid data; otherwise, false.

Returns:

The HasData property value.

SaveToFilePath: str

File path the image data was written to if the SaveToFile method has been called successfully; otherwise, null / None.

Returns:

The SaveToFilePath property value.

Time: datetime.datetime

Date and Time (UTC) of the image.

Returns:

The Time property value.

Title: str

Title of the image, as specified by the user.

Returns:

The Title property value.

This property is assigned by the user, and is not derived from XProtect web-services results.

def SaveToFile(self, filePath: str, timeFormat: str = '%Y%m%d_%H%M%S_%Z') -> None:

Saves the JPEG image data (Data property) to the specified file path.

Arguments:
  • filePath: File path to save the JPEG data to.
  • timeFormat: Date format string to use if the "{time}" placeholder was specified in the filePath argument.
    Default is "%Y%m%d_%H%M%S_%Z" (e.g. 20230716_193747_UTC).
Raises:
  • XPWException: filepath argument is null or an empty string.
    timeFormat argument is null or an empty string.
    The method fails for any other reason.

If the Data property is empty then nothing is saved and no exception is raised.

Use the "{time}" placeholder (case-sensitive) to insert the formatted Time property value in the filePath. The formatting is controlled by the timeFormat argument. Example filePath: ". ests\iPadCam01_{time}.jpg".

Use the "{title}" placeholder (case-sensitive) to insert the Title property value in the filePath.
Example filePath: ". ests{title}_{time}.jpg".

The resolved filePath argument will be stored in the SaveToFilePath property if the file is successfully saved.