Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes | Private Member Functions
scp-dbus-service.GroupPhysicalDevicesRequest Class Reference

List of all members.

Public Member Functions

def __init__
def __del__

Public Attributes

 devices
 reply_handler
 error_handler
 deviceobjs
 physdevs

Private Member Functions

def _group

Detailed Description

Definition at line 198 of file scp-dbus-service.py.


Constructor & Destructor Documentation

def scp-dbus-service.GroupPhysicalDevicesRequest.__init__ (   self,
  devices,
  reply_handler,
  error_handler 
)

Definition at line 199 of file scp-dbus-service.py.

00199 
00200     def __init__ (self, devices, reply_handler, error_handler):
00201         self.devices = devices
00202         self.reply_handler = reply_handler
00203         self.error_handler = error_handler
00204         debugprint ("+%s" % self)
00205 
00206         try:
00207             g_killtimer.add_hold ()
00208             need_resolving = {}
00209             self.deviceobjs = {}
00210             for device_uri, device_dict in self.devices.iteritems ():
00211                 deviceobj = cupshelpers.Device (device_uri, **device_dict)
00212                 self.deviceobjs[device_uri] = deviceobj
00213                 if device_uri.startswith ("dnssd://"):
00214                     need_resolving[device_uri] = deviceobj
00215 
00216             if len (need_resolving) > 0:
00217                 resolver = dnssdresolve.DNSSDHostNamesResolver (need_resolving)
00218                 resolver.resolve (reply_handler=self._group)
00219             else:
00220                 self._group ()
00221         except Exception, e:
00222             g_killtimer.remove_hold ()
00223             self.error_handler (e)

def scp-dbus-service.GroupPhysicalDevicesRequest.__del__ (   self)

Definition at line 224 of file scp-dbus-service.py.

00224 
00225     def __del__ (self):
00226         debugprint ("-%s" % self)


Member Function Documentation

def scp-dbus-service.GroupPhysicalDevicesRequest._group (   self,
  resolved_devices = None 
) [private]

Definition at line 227 of file scp-dbus-service.py.

00227 
00228     def _group (self, resolved_devices=None):
00229         # We can ignore resolved_devices because the actual objects
00230         # (in self.devices) have been modified.
00231         try:
00232             self.physdevs = []
00233             for device_uri, deviceobj in self.deviceobjs.iteritems ():
00234                 newphysicaldevice = PhysicalDevice.PhysicalDevice (deviceobj)
00235                 matched = False
00236                 try:
00237                     i = self.physdevs.index (newphysicaldevice)
00238                     self.physdevs[i].add_device (deviceobj)
00239                 except ValueError:
00240                     self.physdevs.append (newphysicaldevice)
00241 
00242             uris_by_phys = []
00243             for physdev in self.physdevs:
00244                 uris_by_phys.append (map (lambda x: x.uri,
00245                                           physdev.get_devices ()))
00246 
00247             g_killtimer.remove_hold ()
00248             self.reply_handler (uris_by_phys)
00249         except Exception, e:
00250             g_killtimer.remove_hold ()
00251             self.error_handler (e)


Member Data Documentation

scp-dbus-service.GroupPhysicalDevicesRequest.deviceobjs

Definition at line 208 of file scp-dbus-service.py.

scp-dbus-service.GroupPhysicalDevicesRequest.devices

Definition at line 200 of file scp-dbus-service.py.

scp-dbus-service.GroupPhysicalDevicesRequest.error_handler

Definition at line 202 of file scp-dbus-service.py.

scp-dbus-service.GroupPhysicalDevicesRequest.physdevs

Definition at line 231 of file scp-dbus-service.py.

scp-dbus-service.GroupPhysicalDevicesRequest.reply_handler

Definition at line 201 of file scp-dbus-service.py.


The documentation for this class was generated from the following file: