Package brisa :: Package upnp :: Package control_point :: Module device
[hide private]
[frames] | no frames]

Source Code for Module brisa.upnp.control_point.device

 1  # Licensed under the MIT license 
 2  # http://opensource.org/licenses/mit-license.php or see LICENSE file. 
 3  # Copyright 2007-2009, Brisa team <brisa-develop@garage.maemo.org> 
 4   
 5  """ Control point side device implementation. 
 6   
 7  If you're using the control point high level API with no modifications on the 
 8  global flags (located on module brisa), then you shouldn't need to create this 
 9  class manually. 
10   
11  The framework default response to a device arrival is to build it and its 
12  services automatically and forward it to your control point on the 
13  "new_device_event" subscribed callback. This callback will receive the device 
14  already ready for all actions. 
15   
16  Service objects contained by a device should be retrieved using the method 
17  Device.get_service_by_type or accessing the Device.services dictionary directly. 
18  """ 
19   
20  import uuid 
21  import brisa 
22   
23  from brisa.core import log 
24  from brisa.core.network import url_fetch 
25  from brisa.upnp.base_device import BaseDevice, BaseDeviceIcon 
26  from brisa.upnp.control_point.device_builder import DeviceAssembler 
27  from brisa.upnp.upnp_defaults import UPnPDefaults 
28 29 30 -class Device(BaseDevice):
31 """ Represents an UPnP device. 32 33 Consult http://upnp.org/standardizeddcps/basic.asp as a basic reference. 34 """ 35
36 - def add_device(self, device):
37 if not BaseDevice.add_device(self, device): 38 # Could not add device 39 return False 40 if brisa.__skip_soap_service__: 41 return 42 43 # Auto generate soap service 44 self._generate_soap_services_for_device(device)
45
46 - def generate_soap_services(self):
47 """ Generates soap services for services and devices contained this 48 device. 49 """ 50 # Set SOAPService to each device service 51 self._generate_soap_services_for_device(self) 52 53 # Set SOAPService to each embedded child device 54 for child_device in self.devices.values(): 55 self._generate_soap_services_for_device(child_device)
56
57 - def _generate_soap_services_for_device(self, device):
58 """ Generates soap services for a single device 59 60 @param device: device to generate soap services from 61 @type device: Device 62 """ 63 for k, service in device.services.items(): 64 service.generate_soap_service()
65 66 @classmethod
67 - def get_from_location(cls, location):
68 return DeviceAssembler(cls(), location).mount_device()
69 70 @classmethod
71 - def get_from_location_async(cls, location, callback, cargo):
72 DeviceAssembler(cls(), location).mount_device_async(callback, cargo)
73 74 @classmethod
75 - def get_from_file(cls, location, filename):
76 return DeviceAssembler(cls(), location, filename).mount_device()
77 78 @classmethod
79 - def get_from_file_async(cls, location, filename, callback, cargo):
80 DeviceAssembler(cls(), location, filename).mount_device_async(callback, 81 cargo)
82