coherence.upnp.core.service (module)

Services

This module contains several classes related to services:

Service

Object representing a device’s service.

ServiceServer

A Service server.

scpdXML

A twisted.web.resource.Resource represing xml’s data for SCPD.

Note

SCPD is a Service Control Point Definition, for defining the actions offered by the various services in a UPnP’s network.

ServiceControl

Object to control service’s SOAP actions.

subscribe(service)[source]
unsubscribe(service)[source]
class Service(service_type, service_id, location, control_url, event_sub_url, presentation_url, scpd_url, device)[source]

Bases: eventdispatcher.eventdispatcher.EventDispatcher, coherence.log.LogAble

This class represents a Device’s service. It takes care of initializing the device’s service. Emits events which will be received by Device.

Note

This class initializes some events outside this class. This is done this way to make easier to make connections between this service and the module dbus_service, which uses some events triggered by StateVariable.

Warning

This class is special regarding EventDispatcher, because some events are initialized outside this class by the class StateVariable.

    Changed in version 0.9.0:
  • Migrated from extern.louie to EventDispatcher

  • The emitted events changed:

    • Coherence.UPnP.Service.detection_completed => service_detection_completed
    • Coherence.UPnP.Service.detection_failed => service_detection_failed
    • Coherence.UPnP.DeviceClient.Service.Event.processed => service_event_processed
    • Coherence.UPnP.DeviceClient.Service.notified => service_notified
logCategory = 'service_client'
detection_completed
as_tuples()[source]
as_dict()[source]
_get_client(name)[source]
remove()[source]
get_device()[source]
get_type()[source]
set_timeout(timeout)[source]
get_timeout()[source]
get_id()[source]
get_sid()[source]
set_sid(sid)[source]
get_actions()[source]
get_scpdXML()[source]
get_action(name)[source]
get_state_variables(instance)[source]
get_state_variable(name, instance=0)[source]
get_control_url()[source]
get_event_sub_url()[source]
get_presentation_url()[source]
get_scpd_url()[source]
get_base_url()[source]
subscribe()[source]
unsubscribe()[source]
subscribe_for_variable(var_name, instance=0, callback=None, signal=False)[source]
renew_subscription()[source]
process_event(event)[source]
parse_actions()[source]
class ServiceServer(id, version, backend)[source]

Bases: coherence.log.LogAble

logCategory = 'service_server'
_release()[source]
get_action(action_name)[source]
get_actions()[source]
get_variables()[source]
get_subscribers()[source]
rm_notification(result, d)[source]
new_subscriber(subscriber)[source]
get_id()[source]
get_type()[source]
create_new_instance(instance)[source]
remove_instance(instance)[source]
set_variable(instance, variable_name, value, default=False)[source]
get_variable(variable_name, instance=0)[source]
build_single_notification(instance, variable_name, value)[source]
build_last_change_event(instance=0, force=False)[source]
propagate_notification(notify)[source]
check_subscribers()[source]
check_moderated_variables()[source]
is_variable_moderated(name)[source]
simulate_notification()[source]
get_scpdXML()[source]
register_vendor_variable(name, implementation='optional', instance=0, evented='no', data_type='string', dependant_variable=None, default_value=None, allowed_values=None, has_vendor_values=False, allowed_value_range=None, moderated=False)[source]

enables a backend to add an own, vendor defined, StateVariable to the service

@ivar name: the name of the new StateVariable @ivar implementation: either ‘optional’ or ‘required’ @ivar instance: the instance number of the service that variable

should be assigned to, usually ‘0’
@ivar evented: boolean, or the special keyword ‘never’ if the variable
doesn’t show up in a LastChange event too
@ivar data_type: ‘string’,’boolean’,’bin.base64’ or
various number formats
@ivar dependant_variable: the name of another StateVariable that
depends on this one
@ivar default_value: the value this StateVariable should have by
default when created for another instance of in the service

@ivar allowed_values: a C{list} of values this StateVariable can have @ivar has_vendor_values: boolean if there are values outside

the allowed_values list too
@ivar allowed_value_range: a C{dict} of ‘minimum’,’maximum’
and ‘step’ values
@ivar moderated: boolean, True if this StateVariable should only be
evented via a LastChange event
register_vendor_action(name, implementation, arguments=None, needs_callback=True)[source]

enables a backend to add an own, vendor defined, Action to the service

@ivar name: the name of the new Action @ivar implementation: either ‘optional’ or ‘required’ @ivar arguments: a C{list} if argument C{tuples},

like (name,direction,relatedStateVariable)
@ivar needs_callback: this Action needs a method in the backend
or service class
init_var_and_actions()[source]
class scpdXML(server, control=None)[source]

Bases: twisted.web.static.Data, coherence.log.LogAble

logCategory = 'service_scpdxml'
render(request)[source]

Render a given resource. See L{IResource}’s render method.

I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.

render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.

Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.

@see: L{IResource.render}

build_xml()[source]
class ServiceControl[source]

Bases: coherence.log.LogAble

get_action_results(result, action, instance)[source]

check for out arguments if yes: check if there are related ones to StateVariables with

non A_ARG_TYPE_ prefix if yes: check if there is a call plugin method for this action

if yes: update StateVariable values with call result if no: get StateVariable values and

add them to result dict
soap__generic(*args, **kwargs)[source]

generic UPnP service control method, which will be used if no soap_ACTIONNAME method in the server service control class can be found