2008-09-16 21 views
4

Bir PropertyNotified sinyali sırasında işleyicimden bir org.freedesktop.Hal.Device GetProperty çağırıyorum. Yalnızca GetProperty'yi eklenmiş veya değiştirilmiş mülklerde arıyorum.Ne zaman hal özellikleri güncelleştirilir

Özellik eklerken GetProperty'yi çağırdığımda, org.freedesktop.Hal.NoSuchProperty istisnası alıyorum. Ben de değişiklikler sırasında, eski değerleri alıyorum.

GetProperty'yi ne zaman arayayım? Hangi yarış koşulları dahil?

cevap

1

Nasıl hakkında DeviceExists yöntemi (gibi here):

# 
# _CBHalDeviceConnected 
# 
# INTERNAL 
# 
# Callback triggered when a device is connected through Hal. 
# 

def _CBHalDeviceConnected(self, obj_path): 
... 
self.device.connect_to_signal("PropertyModified", 
    self._CBHalDeviceAuthStateChanged) 
... 

# 
# _CBHalDeviceAuthStateChanged 
# 
# INTERNAL 
# 
# Callback triggered when a Hal device property is changed, 
# for checking authorization state changes 
# 

def _CBHalDeviceAuthStateChanged(self,num_changes,properties): 
for property in properties: 
property_name, added, removed = property 
if property_name == "pda.pocketpc.password": 
self.logger.info("_CBHalDeviceAuthStateChanged: 
    device authorization state changed: reauthorizing") 
self._ProcessAuth() 

HAL 0.5.10 Specification
D-Bus Specification
:

if device.PropertyExists('info.product'): 
     return device.GetProperty('info.product') 
    return "unknown" 

Ve sinyali (ex from real world) PropertyModified 10