iotcs.client.device.storage module

class iotcs.client.device.storage.StorageObjectBase(delegate)

Bases: iotcs.client.client.StorageObject

A base call for storage object implementations.

Create a StorageObjectBase instance.

class SyncEventImpl(source, virtualDevice, name)

Bases: iotcs.client.client.SyncEvent

An event passed to the setOnSync() SyncCallback.

This event occurs when an attribute value’s content refers to a StorageObject and has been successfully synchronized, or has failed to be synchronized.

Create a SyncEventImpl instance.

getName()

Return the name of the attribute, action, or format.

Return the name of the attribute, action, or format that this event is associated with.

Returns:the name, or None if sync() was called independently
getSource()

Return the StorageObject source of this event.

:return the storageObject, never None

getVirtualDevice()

Return the virtual device that is the source of the event.

Returns:the virtual device, or None if sync() was called independently
addSyncEvent(syncEvent)

Add syncEvent to syncEvents.

If syncCallback is None do nothing.

createSyncEvent()

Create a SyncEvent.

Returns:a SyncEvent instance
delegate
eventLock
getDelegate()

Return delegate.

Returns:delegate
getSyncEvents()

Return syncEvents.

Returns:syncEvents
handleStateChange()

Perform necessary tasks when the state changes.

setOnSync(callback)

Set a StorageObject.SyncCallback.

The callback is invoked when the content referred to by this StorageObject is synchronized.

Parameters:callback – a StorageObject.SyncCallback to invoke when there is an error setting a value, if None, the existing syncCallback is removed.
sync()

Notify the library to sync content with the storage cloud.

The direction of the sync, upload or download, depends on whether inputPath or the outputPath have been set. This method does not start any uploads or downloads if sycn status is other than NOT_IN_SYNC.

This is a non-blocking call. The sync is performed on a separate thread on this StorageObject.

If the input path cannot be read, or the output path cannot be written, an OSError is raised. Any I/O exceptions during the background sync are reported through the virtual device error callback of the virtual device.

Raises:ValueError – if both input path and output path are None
syncEvents
class iotcs.client.device.storage.StorageObjectImpl(directlyConnectedDevice, delegate)

Bases: iotcs.client.device.storage.StorageObjectBase

An implementation of StorageObjectBase.

Create a StorageObjectImpl instance.

Parameters:
  • directlyConnectedDevice – the messaging.client.device.DirectlyConnectedDevice with messaging.client.StorageObject attributes.
  • delegate – the messaging.client.StorageObject to handle storage operations.
createSyncEvent()

Create a SyncEvent.

Returns:a SyncEvent instance
deviceForSyncEvent
handleStateChange()

Handle changes in sync status.

nameForSyncEvent
setSyncEventInfo(virtualDevice, nameForSyncEvent)

Set the virtual device and name for a sync event.

Parameters:
  • virtualDevice – a VirtualDevice instance
  • nameForSyncEvent – a name for a sync event
Returns:

storageDispatcher
sync()

Synchronize the content with storage cloud service.