buffet_dbus_helper.py revision a2b3d9fee5ae16d22819168daa5d1e2df6e63e0d
1# Copyright 2014 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import dbus 6 7from autotest_lib.client.cros import dbus_util 8 9MANAGER_INTERFACE = 'org.chromium.Buffet.Manager' 10 11class BuffetDBusHelper(object): 12 """Delegate representing an instance of buffet.""" 13 14 def __init__(self): 15 """Construct a BuffetDBusHelper. 16 17 You should probably use get_helper() above rather than call this 18 directly. 19 20 @param manager_proxy: DBus proxy for the Manager object. 21 22 """ 23 bus = dbus.SystemBus() 24 manager_proxy = bus.get_object('org.chromium.Buffet', 25 '/org/chromium/Buffet/Manager') 26 self.manager = dbus.Interface(manager_proxy, MANAGER_INTERFACE) 27 self.properties = dbus.Interface(manager_proxy, 28 'org.freedesktop.DBus.Properties') 29 30 def __getattr__(self, name): 31 components = name.split('_') 32 name = ''.join(x.title() for x in components) 33 dbus_value = self.properties.Get(MANAGER_INTERFACE, name) 34 return dbus_util.dbus2primitive(dbus_value) 35