upnpy package

Submodules

upnpy.utils module

upnpy.utils.make_http_request(url, data=None, headers=None)

Helper function for making HTTP requests

Helper function for making HTTP requests using urllib.

Parameters
  • url (str) – The URL to which a request should be made

  • data (str) – Provide data for the request. Request method will be set to POST if data is provided

  • headers (dict) – Provide headers to send with the request

Returns

A urllib.Request.urlopen object

Return type

urllib.Request.urlopen

upnpy.utils.parse_device_type(device_type)

Parse the the deviceType string

Parses only the deviceType portion of the device type string

Parameters

device_type – Full device type string

Returns

Parsed device type

Return type

str

upnpy.utils.parse_http_header(header, header_key)

Parse HTTP header value

Parse the value of a specific header from a RAW HTTP response.

Parameters
  • header (str) – String containing the RAW HTTP response and headers

  • header_key (str) – The header name of which to extract a value from

Returns

The value of the header

Return type

str

upnpy.utils.parse_service_id(service_id)

Parse the the serviceID string

Parses only the serviceID portion of the service ID string

Parameters

service_id – Full device type string

Returns

Parsed service ID

Return type

str

upnpy.exceptions module

exception upnpy.exceptions.ActionNotFoundError(message, action_name)

Bases: Exception

Custom Action exception

Custom Action exception class. Raised whenever a particular action is not available for a service.

exception upnpy.exceptions.ArgumentError(message, argument)

Bases: Exception

Custom Argument exception

Custom Argument exception class. Raised whenever an error has been detected during action invocation.

exception upnpy.exceptions.HostnameError(message, base_host, scpd_host)

Bases: Exception

Custom exception for when a device’s SCPD host doesn’t match the base URL’s host

Raised whenever the SCPD host doesn’t match the base URL host.

exception upnpy.exceptions.IGDError

Bases: Exception

Custom Internet Gateway Device exception

Custom IGD exception class. Raised whenever a problem with the IGD has been detected.

exception upnpy.exceptions.NotAvailableError

Bases: Exception

Custom exception for when a certain URL could not be retrieved

Custom element not retrieved exception class. Raised whenever a value needed to be accessed could not be retrieved from the URL.

exception upnpy.exceptions.NotRetrievedError

Bases: Exception

Custom exception for objects that have not been retrieved

Custom object not retrieved exception class. Raised whenever a certain property for a device or service was not retrieved.

exception upnpy.exceptions.SOAPError(description, code)

Bases: Exception

Custom SOAP exception

Custom SOAP exception class. Raised whenever an error response has been received during action invocation.

exception upnpy.exceptions.SchemeError(message, scheme)

Bases: Exception

Custom exception for when an invalid scheme has been found

Raised whenever an invalid scheme was found.

exception upnpy.exceptions.ServiceNotFoundError(message, service_name)

Bases: Exception

Custom Service exception

Custom Service exception class. Raised whenever a particular service was not found for a device.

Module contents

License

MIT License

Copyright (c) 2019 5kyc0d3r

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.