4.1.2.2. UpnpTask

class fluxclient.upnp.UpnpTask(uuid, client_key, ipaddr=None, device_metadata=None, remote_profile=None, backend_options={}, lookup_callback=None, lookup_timeout=inf)

UpnpTask provides some configuration methods for the device. When creating a UpnpTask instance, the argument uuid is required. If parameter device_metadata is not given, UpnpTask will use lookup_callback and lookup_timeout to create a UpnpDiscover instance and try to get metadata from network.

Parameters:
  • uuid (uuid.UUID) – Device uuid, set UUID(int=0) while trying to connect via ip address.
  • client_key (encrypt.KeyObject) – Client key to connect to device.
  • ipaddr (str) – IP Address of the machine.
  • device_metadata (dict) – This is an internal parameter, which is not recommended to provide because it may has different definitions in different versions.
  • backend_options (dict) – More configuration for UpnpTask.
  • lookup_callback (callable) – Invoke repeatedly while looking for device.
  • lookup_timeout (float) – Raise an error if the program can not find the device in a limited time.
Raises:
  • UpnpError – For protocol or operation error.
  • socket.error – For system defined socket error.
close()

Closes the upnp socket connection. After close(), any other method should not be called anymore.

authorized

Indicates whether the connection has been authorized with a correct password or RSA key. If the connection is not authorized, you must call authorize_with_password first to authorize.

connected

Indicates whether the upnp connection is connected with the device

authorize_with_password(password)

Authorizes via password, only use when the RSA key has not been trusted from device.

Parameters:password (str) – Device password
add_trust(label, key)

Adds a client_key to device trust list

Parameters:
  • label (str) – Key label will show for human only
  • key (object) – A vaild RSA key object or pem
Returns:

Key hash

Return type:

str

list_trust()

Gets all trusted key in the device

Returns:((label, key hash), (label, key hash), ...)
remove_trust(access_id)

Removes a trusted key

Parameters:access_id (str) – Key hash which will be removed
rename(new_name)

Renames the device

Parameters:new_name (str) – New device name
modify_password(old_password, new_password, reset_acl=True)

Changes the device password, if reset_acl set to True, all other authorized user will be deauthorized.

Parameters:
  • old_password (str) – Old device password
  • new_password (str) – New device password
  • reset_acl (bool) – Clear authorized user list in device
modify_network(**settings)

Modifies the device network, details will be revealed in future documentation.

get_wifi_list()

Gets wifi lists discovered from the device