4.1.1. FluxRobot

fluxclient.robot provides an interface to control a FLUX device.

An example to connect and control a device:

from fluxclient.commands.misc import get_or_create_default_key
from fluxclient.robot import FluxRobot

client_key = get_or_create_default_key("./sdk_connection.pem")
robot = FluxRobot(('192.168.18.114', 23811), client_key)

Note

You might want to check this link for details.

# Case 1: Get device from uuid device = discover_device(uuid) robot = device.connect_robot(client_key)

# Case 2: Connect to robot directly robot = FluxRobot((metadata[“ipaddr”], 23811), client_key)

class fluxclient.robot.robot.FluxRobot(endpoint, client_key, device=None, ignore_key_validation=False)

A FluxRobot object represents a live connection with a FLUX device.

Parameters:
  • endpoint (tuple) – A tuple contain a pair of IP address and port to connect. For example: (“192.168.1.1”, 23811)
  • client_key (encrypt.KeyObject) – Client identify key
  • device (dict) – Device instance to assign value because it may has different definition in different version.
list_files(path)

List files on the device.

Parameters:path (str) – Path on device, must start with /SD/ or /USB/
Returns:An array of files and directories. Each array element is a tuple, first is a boolean present this name is a folder or not and second is the name of the file or folder.
Return type:list
file_info(path)

Gets fcode information from specific file path.

Parameters:path (str) – File path on the device
Returns:[ {“f-code-metadata-key”: “f-code-metada-value”, ...}, [(“image”, b’image buffer object’), ...] ] The first return element in array is a key-value information of f-code the second is a list of preview images. Image list length may be 0.
Return type:list
file_md5(path)

Gets file md5 on the device.

Parameters:path (str) – File path on the device
Returns:MD5 hex
Return type:str
mkdir(path)

Creates a folder on the device storage.

Parameters:path (str) – Path to be created
rmdir(path)

Removes folder on the device storage.

Parameters:path (str) – Path to be removed
cpfile(source_path, dist_path)

Copies a file on the device.

Parameters:
  • source_path (str) – File can be on device or usb disk
  • dist_path (str) – File can be copied only to the device
rmfile(path)

Removes a file on the device.

Parameters:path (str) – File to be deleted
download_file(path, stream, process_callback=None)

Downloads a file from the device.

Parameters:
  • path (str) – File on device for download
  • stream (filelike_obj) – A local file-like object to write
  • process_callback (function) – A callable object which will be invoked during download progress
upload_file(filename, upload_to='#', process_callback=None)

Uploads a file to the device.

Parameters:
  • filename (str) – File to upload to device
  • upload_to (str) – Path on device to upload to
  • process_callback (function) – A callable object which will be invoked during upload progress
upload_stream(stream, mimetype, size, upload_to='#', process_callback=None)

Uploads a file to the device. ( In file stream )

Parameters:
  • stream (file) – Filelike object
  • mimetype (str) – Contents mimetype
  • size (int) – Contents size
  • upload_to (str) – Path on device to upload to
  • callback (function) – A callable object which will be invoke during upload progress
yihniwimda_upload_stream(mimetype, size, upload_to='#')

Yes, I have no idea what I’m doing about upload stream. You can use it if and only if you have any idea about this:

for feeder in robot.yihniwimda_upload_stream(...):
recived_size = feeder(buffer) print(“%i bytes sent” % recived_size)

print(“Done”)

select_file(path)

Selects a file to run.

Parameters:path (str) – Path on device
start_play()

Starts currently selected task.

pause_play()

Pauses current task.

abort_play()

Aborts current task.

resume_play()

Resumes current task.

report_play()

Reports current task status.

play_info()

Shows current task info.

quit_play()

Quits from current task status.

deviceinfo

Gets the device information

config

Gets a subscriptable device config object.

kick()

Kicks a work session which occupied the device.

update_firmware(stream, size, process_callback=None)

Uploadshen and t updates a flux device firmware

scan()

Begins a scanning task and return a scan object

maintain()

Begins a maintaining task and return a scan object

close()

Closes a device connection