digi.xbee.filesystem module

class digi.xbee.filesystem.FileSystemElement(name, path, size=0, is_directory=False)[source]

Bases: object

Class used to represent XBee file system elements (files and directories).

Class constructor. Instantiates a new FileSystemElement with the given parameters.

Parameters:
  • name (String) – the name of the file system element.
  • path (String) – the absolute path of the file system element.
  • size (Integer) – the size of the file system element, only applicable to files.
  • is_directory (Boolean) – True if the file system element is a directory, False if it is a file.
name

Returns the file system element name.

Returns:the file system element name.
Return type:String
path

Returns the file system element absolute path.

Returns:the file system element absolute path.
Return type:String
size

Returns the file system element size.

Returns:the file system element size. If element is a directory, returns ‘0’.
Return type:Integer
is_directory

Returns whether the file system element is a directory or not.

Returns:True if the file system element is a directory, False otherwise.
Return type:Boolean
is_secure

Returns whether the file system element is a secure element or not.

Returns:True if the file system element is secure, False otherwise.
Return type:Boolean
exception digi.xbee.filesystem.FileSystemException[source]

Bases: digi.xbee.exception.XBeeException

This exception will be thrown when any problem related with the XBee device file system occurs.

All functionality of this class is the inherited from Exception.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception digi.xbee.filesystem.FileSystemNotSupportedException[source]

Bases: digi.xbee.filesystem.FileSystemException

This exception will be thrown when the file system feature is not supported in the device.

All functionality of this class is the inherited from Exception.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class digi.xbee.filesystem.LocalXBeeFileSystemManager(xbee_device)[source]

Bases: object

Helper class used to manage the local XBee file system.

Class constructor. Instantiates a new LocalXBeeFileSystemManager with the given parameters.

Parameters:xbee_device (XBeeDevice) – the local XBee device to manage its file system.
is_connected

Returns whether the file system manager is connected or not.

Returns:True if the file system manager is connected, False otherwise.
Return type:Boolean
connect()[source]

Connects the file system manager.

Raises:
disconnect()[source]

Disconnects the file system manager and restores the device connection.

Raises:XBeeException – if there is any error restoring the XBee device connection.
get_current_directory()[source]

Returns the current device directory.

Returns:the current device directory.
Return type:String
Raises:FileSystemException – if there is any error getting the current directory or the function is not supported.
change_directory(directory)[source]

Changes the current device working directory to the given one.

Parameters:directory (String) – the new directory to change to.
Returns:the current device working directory after the directory change.
Return type:String
Raises:FileSystemException – if there is any error changing the current directory or the function is not supported.
make_directory(directory)[source]

Creates the provided directory.

Parameters:directory (String) – the new directory to create.
Raises:FileSystemException – if there is any error creating the directory or the function is not supported.
list_directory(directory=None)[source]

Lists the contents of the given directory.

Parameters:directory (String, optional) – the directory to list its contents. Optional. If not provided, the current directory contents are listed.
Returns:list of :class:`.FilesystemElement` objects contained in the given (or current) directory.
Return type:List
Raises:FileSystemException – if there is any error listing the directory contents or the function is not supported.
remove_element(element_path)[source]

Removes the given file system element path.

Parameters:element_path (String) – path of the file system element to remove.
Raises:FileSystemException – if there is any error removing the element or the function is not supported.
move_element(source_path, dest_path)[source]

Moves the given source element to the given destination path.

Parameters:
  • source_path (String) – source path of the element to move.
  • dest_path (String) – destination path of the element to move.
Raises:

FileSystemException – if there is any error moving the element or the function is not supported.

put_file(source_path, dest_path, secure=False, progress_callback=None)[source]

Transfers the given file in the specified destination path of the XBee device.

Parameters:
  • source_path (String) – the path of the file to transfer.
  • dest_path (String) – the destination path to put the file in.
  • secure (Boolean, optional) – True if the file should be stored securely, False otherwise. Defaults to False.
  • progress_callback (Function, optional) –

    function to execute to receive progress information.

    Takes the following arguments:

    • The progress percentage as integer.
Raises:

FileSystemException – if there is any error transferring the file or the function is not supported.

put_dir(source_dir, dest_dir=None, progress_callback=None)[source]

Uploads the given source directory contents into the given destination directory in the device.

Parameters:
  • source_dir (String) – the local directory to upload its contents.
  • dest_dir (String, optional) – the remote directory to upload the contents to. Defaults to current directory.
  • progress_callback (Function, optional) –

    function to execute to receive progress information.

    Takes the following arguments:

    • The file being uploaded as string.
    • The progress percentage as integer.
Raises:

FileSystemException – if there is any error uploading the directory or the function is not supported.

get_file(source_path, dest_path, progress_callback=None)[source]

Downloads the given XBee device file in the specified destination path.

Parameters:
  • source_path (String) – the path of the XBee device file to download.
  • dest_path (String) – the destination path to store the file in.
  • progress_callback (Function, optional) –

    function to execute to receive progress information.

    Takes the following arguments:

    • The progress percentage as integer.
Raises:

FileSystemException – if there is any error downloading the file or the function is not supported.

format_filesystem()[source]

Formats the device file system.

Raises:FileSystemException – if there is any error formatting the file system.
get_usage_information()[source]

Returns the file system usage information.

Returns:collection of pair values describing the usage information.
Return type:Dictionary
Raises:FileSystemException – if there is any error retrieving the file system usage information.
get_file_hash(file_path)[source]

Returns the SHA256 hash of the given file path.

Parameters:file_path (String) – path of the file to get its hash.
Returns:the SHA256 hash of the given file path.
Return type:String
Raises:FileSystemException – if there is any error retrieving the file hash.