def groupStarted(properties): print "groupStarted: " + str(properties) g_obj = dbus.SystemBus().get_object('fi.w1.wpa_supplicant1',properties['group_object']) res = g_obj.GetAll('fi.w1.wpa_supplicant1.Group', dbus_interface=dbus.PROPERTIES_IFACE, byte_arrays=True) print "Group properties: " + str(res) hostnamehex = hostname.encode('hex') hostnamemessage = '2002'+'{:04X}'.format(len(hostname))+hostnamehex ipmessage = '' if ipstr != '': # The spec supportes multiple ip attributes. However, Windows will only try the first one iphex = ipstr.encode('hex') ipmessage = '2005'+'{:04X}'.format(len(iphex)/2)+iphex capandhostmessage = '0001372001000105' + hostnamemessage + ipmessage innerarray = [] for c in capandhostmessage.decode('hex'): innerarray.append(dbus.Byte(c)) g_obj.Set('fi.w1.wpa_supplicant1.Group', 'WPSVendorExtensions', dbus.Array([dbus.Array(innerarray, signature=dbus.Signature('ay'))], signature=dbus.Signature('ay')),dbus_interface=dbus.PROPERTIES_IFACE) g_obj = dbus.SystemBus().get_object('fi.w1.wpa_supplicant1',properties['group_object']) res = g_obj.GetAll('fi.w1.wpa_supplicant1.Group', dbus_interface=dbus.PROPERTIES_IFACE, byte_arrays=True) print "Group properties: " + str(res) event.set()
def add_connection(self): n_con = dbus.Dictionary({ "type": "generic", "uuid": str(uuid.uuid4()), "id": "xmm7360", "interface-name": "wwan0" }) addr = dbus.Dictionary({ "address": self.ip_addr, "prefix": dbus.UInt32(32) }) n_ip4 = dbus.Dictionary({ "address-data": dbus.Array([addr], signature=dbus.Signature("a{sv}")), "gateway": self.ip_addr, "method": "manual", "dns": dbus.Array(self.dbus_ipv4_dns(), signature=dbus.Signature("u")) }) n_ip6 = dbus.Dictionary({"method": "ignore"}) add_con = dbus.Dictionary({ "connection": n_con, "ipv4": n_ip4, "ipv6": n_ip6 }) self.settings.AddConnection(add_con)
def apply_network_changes(settings_dict): if settings_dict['Method'] in ['manual', 'dhcp']: # non NFS setup path = settings_dict['path'] service = connman.get_service_interface(path) ipv4_configuration = { 'Method': make_variant(settings_dict['Method']), 'Address': make_variant(settings_dict['Address']), 'Netmask': make_variant(settings_dict['Netmask']) } if 'Gateway' in settings_dict: ipv4_configuration['Gateway'] = make_variant( settings_dict['Gateway']) service.SetProperty('IPv4.Configuration', ipv4_configuration) time.sleep(2) dns = [] if 'DNS_1' in settings_dict: dns.append(settings_dict['DNS_1']) if 'DNS_2' in settings_dict: dns.append(settings_dict['DNS_2']) # duplicate SetProperty message works around connman dns forwarder bug service.SetProperty('Nameservers.Configuration', dbus.Array(dns, signature=dbus.Signature('s'))) service.SetProperty('Nameservers.Configuration', dbus.Array(dns, signature=dbus.Signature('s'))) elif settings_dict['Method'].startswith('nfs_'): ip_value = None if settings_dict['Method'] == 'nfs_dhcp': ip_value = 'dhcp' if settings_dict['Method'] == 'nfs_manual': ip_value = create_cmdline_nfs_manual_string(settings_dict) update_cmdline_file(UPDATE_NETWORK_DETAILS_FILE, 'ip', ip_value)
def service_connect_handler(self, interface, object_path, method, args, ok, err): if interface == Network().get_interface_name() and method == "Connect": uuid = args[0] name = uuid16_to_name(uuid128_to_uuid16(uuid)) d = Device(object_path) conn = self.find_active_connection(d.Address, "panu") if conn: err(dbus.DBusException(_("Already connected"))) else: params = {} params["bluetooth"] = {"name": "bluetooth", "bdaddr": str(d.Address), "type": "panu"} params["connection"] = {"autoconnect": False, "id": str("%s on %s") % (name, d.Alias), "uuid": str(uuid1()), "type": "bluetooth"} params['ipv4'] = {'addresses': dbus.Array([], dbus.Signature("i")), 'dns': dbus.Array([], dbus.Signature("i")), "method": "auto", "routes": dbus.Array([], dbus.Signature("i"))} NewConnectionBuilder(self, params, ok, err) return True elif interface == Network().get_interface_name() and method == "Disconnect": d = Device(object_path) active_conn_path = self.find_active_connection(d.Address, "panu") if active_conn_path: self.bus.call_blocking("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager", "org.freedesktop.NetworkManager", "DeactivateConnection", "o", [active_conn_path]) ok() return True
def test_50_create_no_part_scan(self): # create a partition on the file (future loop device) ret, out = self.run_command("parted %s mklabel msdos" % self.LOOP_DEVICE_FILENAME) self.assertEqual(ret, 0) ret, out = self.run_command("parted %s mkpart primary ext2 1 10" % self.LOOP_DEVICE_FILENAME) self.assertEqual(ret, 0) opts = dbus.Dictionary({"no-part-scan": dbus.Boolean(True)}, signature=dbus.Signature('sv')) with open(self.LOOP_DEVICE_FILENAME, "r+b") as loop_file: fd = loop_file.fileno() loop_dev_obj_path = self.manager.LoopSetup(fd, opts) self.assertTrue(loop_dev_obj_path) self.assertTrue(loop_dev_obj_path.startswith(self.path_prefix)) path, loop_dev = loop_dev_obj_path.rsplit("/", 1) self.addCleanup(self.run_command, "losetup -d /dev/%s" % loop_dev) loop_dev_obj = self.get_object(loop_dev_obj_path) # should use the right backing file raw = self.get_property(loop_dev_obj, '.Loop', 'BackingFile') # transcription to array of Bytes to string plus adding the trailing \0 backing_file = self.str_to_ay( os.path.join(os.getcwd(), self.LOOP_DEVICE_FILENAME)) raw.assertEqual(backing_file) # should use the whole file except for the first 4096 bytes (offset) size = self.get_property(loop_dev_obj, ".Block", "Size") size.assertEqual(10 * 1024**2) # should be writable ro = self.get_property(loop_dev_obj, ".Block", "ReadOnly") ro.assertFalse() # partitions shouldn't be scanned self.assertFalse(os.path.exists("/dev/%sp1" % loop_dev)) # detach the file an try it again, this time requesting the partitions to be scanned self.run_command("losetup -d /dev/%s" % loop_dev) opts = dbus.Dictionary({"no-part-scan": dbus.Boolean(False)}, signature=dbus.Signature('sv')) with open(self.LOOP_DEVICE_FILENAME, "r+b") as loop_file: fd = loop_file.fileno() loop_dev_obj_path = self.manager.LoopSetup(fd, opts) self.assertTrue(loop_dev_obj_path) self.assertTrue(loop_dev_obj_path.startswith(self.path_prefix)) path, loop_dev = loop_dev_obj_path.rsplit("/", 1) self.addCleanup(self.run_command, "losetup -d /dev/%s" % loop_dev) time.sleep(1) # partitions should be scanned self.assertTrue(os.path.exists("/dev/%sp1" % loop_dev))
def test_add_manufacturer_data(self): variant_details = variant_definitions['NEBHNT-OUT1'] advertisement = BluetoothConnectionAdvertisement( 135, 'A1:B2:C3:DD:E5:F6', 'peripheral', variant_details) manufacturer_data = {'name': 'Nebra'} advertisement.add_manufacturer_data('Nebra', manufacturer_data) self.assertEqual( advertisement.manufacturer_data, dbus.Dictionary( {'Nebra': dbus.Array(['name'], signature=dbus.Signature('y'))}, signature=dbus.Signature('qv')))
def update_connection(uuid, method, ip, prefix, gateway, dns1, dns2): bus = dbus.SystemBus() proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings") settings = dbus.Interface(proxy, "org.freedesktop.NetworkManager.Settings") for c_path in settings.ListConnections(): c_proxy = bus.get_object("org.freedesktop.NetworkManager", c_path) c_obj = dbus.Interface( c_proxy, "org.freedesktop.NetworkManager.Settings.Connection") c_settings = c_obj.GetSettings() # Look for the requested connection UUID if c_settings['connection']['uuid'] != uuid: continue print c_settings # add IPv4 setting if it doesn't yet exist if 'ipv4' not in c_settings: c_settings['ipv4'] = {} # clear existing address info if c_settings['ipv4'].has_key('addresses'): del c_settings['ipv4']['addresses'] if c_settings['ipv4'].has_key('address-data'): del c_settings['ipv4']['address-data'] if c_settings['ipv4'].has_key('gateway'): del c_settings['ipv4']['gateway'] # set the method and change properties c_settings['ipv4']['method'] = method if method == "manual": # Add the static IP address, prefix, and gateway addr1 = dbus.Array( [ip_to_int(ip), dbus.UInt32(int(prefix)), ip_to_int(gateway)], signature=dbus.Signature('u')) c_settings['ipv4'][dbus.String(unicode('addresses'))] = dbus.Array( [addr1], signature=dbus.Signature('au')) c_settings['ipv4'][dbus.String(unicode('dns'))] = dbus.Array( [ip_to_int(dns1), ip_to_int(dns2)], signature=dbus.Signature('u')) # Save all the updated settings back to NetworkManager c_obj.Update(c_settings) return True
def test_add_service_data(self): variant_details = variant_definitions['NEBHNT-OUT1'] advertisement = BluetoothConnectionAdvertisement( 140, 'A1:B2:C3:DD:E5:F6', 'peripheral', variant_details) service_uuid = str(uuid.uuid4()) service_data = {'key': 'value'} advertisement.add_service_data(service_uuid, service_data) self.assertEqual( advertisement.service_data, dbus.Dictionary( { service_uuid: dbus.Array(['key'], signature=dbus.Signature('y')) }, signature=dbus.Signature('sv')))
def parse_array_of_array_of_uint32(array): dbus_array_of_array = dbus.Array([], signature=dbus.Signature('au'), variant_level=1) for val in array: dbus_array_of_array.append(parse_array_of_uint32(val)) return dbus_array_of_array
def test_dbus_read_value(self): result = dbus_tools.dbus_to_python( dbus.Array( [dbus.Byte(66), dbus.Byte(97), dbus.Byte(122)], signature=dbus.Signature('y'))) self.assertListEqual(result, [66, 97, 122])
def _set_fstab_mountpoint(self, disk, options): # create a tempdir tmp = tempfile.mkdtemp() self.addCleanup(self._rmtree, tmp) # configuration items as arrays of dbus.Byte mnt = self.str_to_ay(tmp) fstype = self.str_to_ay(self._fs_name) if options: opts = self.str_to_ay(options) else: opts = self.str_to_ay('defaults') # set the new configuration conf = dbus.Dictionary( { 'dir': mnt, 'type': fstype, 'opts': opts, 'freq': 0, 'passno': 0 }, signature=dbus.Signature('sv')) disk.AddConfigurationItem(('fstab', conf), self.no_options, dbus_interface=self.iface_prefix + '.Block')
def wrap_dbus_value(value): if value is None: return VEDBUS_INVALID if isinstance(value, float): return dbus.Double(value, variant_level=1) if isinstance(value, bool): return dbus.Boolean(value, variant_level=1) if isinstance(value, int): return dbus.Int32(value, variant_level=1) if isinstance(value, str): return dbus.String(value, variant_level=1) if isinstance(value, unicode): return dbus.String(value, variant_level=1) if isinstance(value, list): if len(value) == 0: # If the list is empty we cannot infer the type of the contents. So assume unsigned integer. # A (signed) integer is dangerous, because an empty list of signed integers is used to encode # an invalid value. return dbus.Array([], signature=dbus.Signature('u'), variant_level=1) return dbus.Array([wrap_dbus_value(x) for x in value], variant_level=1) if isinstance(value, long): return dbus.Int64(value, variant_level=1) if isinstance(value, dict): # Wrapping the keys of the dictionary causes D-Bus errors like: # 'arguments to dbus_message_iter_open_container() were incorrect, # assertion "(type == DBUS_TYPE_ARRAY && contained_signature && # *contained_signature == DBUS_DICT_ENTRY_BEGIN_CHAR) || (contained_signature == NULL || # _dbus_check_is_valid_signature (contained_signature))" failed in file ...' return dbus.Dictionary( {(k, wrap_dbus_value(v)) for k, v in value.items()}, variant_level=1) return value
def test_configuration_fstab_removable(self): # this test will change /etc/fstab, we might want to revert the changes when it finishes fstab = self.read_file('/etc/fstab') self.addCleanup(self.write_file, '/etc/fstab', fstab) # this might fail in case of stray udev rules or records in /etc/fstab hint_auto = self.get_property_raw(self.cd_device, '.Block', 'HintAuto') self.assertEqual(hint_auto, dbus.Boolean(True)) hint_ignore = self.get_property_raw(self.cd_device, '.Block', 'HintIgnore') self.assertEqual(hint_ignore, dbus.Boolean(False)) hint_partitionable = self.get_property_raw(self.cd_device, '.Block', 'HintPartitionable') self.assertEqual(hint_partitionable, dbus.Boolean(True)) hint_system = self.get_property_raw(self.cd_device, '.Block', 'HintSystem') self.assertEqual(hint_system, dbus.Boolean(False)) # configuration items as arrays of dbus.Byte mnt = self.str_to_ay('/mnt/test') fstype = self.str_to_ay('xfs') opts = self.str_to_ay('defaults') # set the new configuration conf = dbus.Dictionary({'dir': mnt, 'type': fstype, 'opts': opts, 'freq': 0, 'passno': 0}, signature=dbus.Signature('sv')) self.cd_device.AddConfigurationItem(('fstab', conf), self.no_options, dbus_interface=self.iface_prefix + '.Block') hint_auto = self.get_property_raw(self.cd_device, '.Block', 'HintAuto') self.assertEqual(hint_auto, dbus.Boolean(True)) # get the configuration old_conf = self.get_property(self.cd_device, '.Block', 'Configuration') old_conf.assertTrue() # update the configuration new_opts = self.str_to_ay('defaults,noauto') new_conf = copy.deepcopy(old_conf.value) new_conf[0][1]['opts'] = new_opts self.cd_device.UpdateConfigurationItem((old_conf.value[0][0], old_conf.value[0][1]), (new_conf[0][0], new_conf[0][1]), self.no_options, dbus_interface=self.iface_prefix + '.Block') # get the configuration after the update upd_conf = self.get_property(self.cd_device, '.Block', 'Configuration') upd_conf.assertTrue() upd_conf.assertEqual(new_opts, getter=lambda c: c[0][1]['opts']) # 'noauto' option specified, should be reflected in the HintAuto property hint_auto = self.get_property_raw(self.cd_device, '.Block', 'HintAuto') self.assertEqual(hint_auto, dbus.Boolean(False)) # remove the configuration self.cd_device.RemoveConfigurationItem((upd_conf.value[0][0], upd_conf.value[0][1]), self.no_options, dbus_interface=self.iface_prefix + '.Block') upd_conf = self.get_property(self.cd_device, '.Block', 'Configuration') upd_conf.assertFalse() hint_auto = self.get_property_raw(self.cd_device, '.Block', 'HintAuto') self.assertEqual(hint_auto, dbus.Boolean(True))
def GetValue(self): tracing.log.debug("GetValue %s" % self._objectPath) value = dbus.Array([], signature=dbus.Signature('i'), variant_level=1) if 'Value' in self._properties: if self._properties['Value'] != dbus.Array([]): value = self._properties['Value'] return value
def UserDetails(self, userName): """ shadow_expire: return -1 if expiration is disabled. """ userEntity = self.__libuser.lookupUserByName(userName) groups = self.__libuser.enumerateGroupsByUser(userName) if not groups: groups = [''] result = dbus.Dictionary( { 'uid': userEntity.get(libuser.UIDNUMBER)[0], 'gid': userEntity.get(libuser.GIDNUMBER)[0], 'userName': userEntity.get(libuser.USERNAME)[0], 'fullName': userEntity.get(libuser.GECOS)[0], 'homeDirectory': userEntity.get(libuser.HOMEDIRECTORY)[0], 'groups': groups, 'loginShell': userEntity.get(libuser.LOGINSHELL)[0], 'shadowExpire': userEntity.get(libuser.SHADOWEXPIRE)[0], 'shadowMin': userEntity.get(libuser.SHADOWMIN)[0], 'shadowMax': userEntity.get(libuser.SHADOWMAX)[0], 'shadowWarning': userEntity.get(libuser.SHADOWWARNING)[0], 'shadowInactive': userEntity.get(libuser.SHADOWINACTIVE)[0], 'shadowLastChange': userEntity.get( libuser.SHADOWLASTCHANGE)[0], }, signature=dbus.Signature('sv')) return result
def convert_to_dbus_array(payload): payload = bytearray(payload) out = [] for b in payload: out = out + [dbus.Byte(b)] return dbus.Array(out, signature=dbus.Signature('y'))
def test_bytes_to_dbusarray2(self): expected = dbus.Array( [dbus.Byte(0), dbus.Byte(1), dbus.Byte(2)], signature=dbus.Signature('y')) result = dbus_tools.bytes_to_dbusarray(b'\x00\x01\x02') self.assertEqual(expected, result)
def test_bytes_to_dbusarray(self): expected = dbus.Array( [dbus.Byte(70), dbus.Byte(111), dbus.Byte(120)], signature=dbus.Signature('y')) result = dbus_tools.bytes_to_dbusarray(b'Fox') self.assertEqual(expected, result)
def list_spec_properties(spec): """Parse a property spec and return a dict: {'Metadata': {'access': 'read', 'type': 'a{sv}', 'emit': 'true'} 'access' can be: read/write/readwrite 'type' is the dbus data type (dbus.Signature instance) 'emit' can be true/false/invalidates (see dbus spec) """ ANNOTATION_EMITS = "org.freedesktop.DBus.Property.EmitsChangedSignal" def get_emit(element, fallback): for anno in element.findall("annotation"): if anno.attrib["name"] == ANNOTATION_EMITS: emit = anno.attrib["value"] break else: emit = fallback return emit root = ET.fromstring('<?xml version="1.0"?><props>' + spec + '</props>') props = {} root_emit = get_emit(root, "true") for element in root: if element.tag != "property": continue attrs = element.attrib attrs["emit"] = get_emit(element, root_emit) attrs["type"] = dbus.Signature(attrs["type"]) props[attrs.pop("name")] = attrs return props
def testResultTuple(self): """ Test result with tuple. """ result = _info_to_xformer( (("thing", (lambda x: _option_to_tuple(x, 0)), "(bt)"), )) self.assertEqual(result((None, )), [ dbus.Struct((dbus.Boolean(False), dbus.UInt64(0)), signature=dbus.Signature("bt")) ]) self.assertEqual(result((32, )), [ dbus.Struct((dbus.Boolean(True), dbus.UInt64(32)), signature=dbus.Signature("bt")) ])
def add_signal(self, name, dbus_interface=None, signature="", *args, **kwargs): if not dbus_interface: dbus_interface = self.interface if name in self.__class__.__dict__: raise MethodAlreadyExists a = "" for i in range(len(dbus.Signature(signature))): a += ", arg%d" % i exec "def func(self%s): pass" % a func.__name__ = name dec = dbus.service.signal(dbus_interface, signature, *args, **kwargs)(func) setattr(self.__class__, func.__name__, dec) if not dbus_interface in self._dbus_class_table[ self.__class__.__module__ + "." + self.__class__.__name__]: self._dbus_class_table[ self.__class__.__module__ + "." + self.__class__.__name__][dbus_interface] = {} self._dbus_class_table[self.__class__.__module__ + "." + self.__class__.__name__][dbus_interface][ func.__name__] = dec return getattr(self, func.__name__)
def configure_certmonger_renewal_helpers(): """ Create a new CA type for certmonger that will retrieve updated certificates from the dogtag master server. """ cmonger = services.knownservices.certmonger cmonger.enable() if not services.knownservices.dbus.is_running(): # some platforms protect dbus with RefuseManualStart=True services.knownservices.dbus.start() cmonger.start() bus = dbus.SystemBus() obj = bus.get_object('org.fedorahosted.certmonger', '/org/fedorahosted/certmonger') iface = dbus.Interface(obj, 'org.fedorahosted.certmonger') for suffix, args in [ ('', ''), ('-reuse', ' --reuse-existing'), ('-selfsigned', ' --force-self-signed'), ]: name = RENEWAL_CA_NAME + suffix path = iface.find_ca_by_nickname(name) if not path: command = paths.DOGTAG_IPA_CA_RENEW_AGENT_SUBMIT + args iface.add_known_ca( name, command, dbus.Array([], dbus.Signature('s')), # Give dogtag extra time to generate cert timeout=CA_DBUS_TIMEOUT)
def configure_certmonger_renewal(self): """ Create a new CA type for certmonger that will retrieve updated certificates from the dogtag master server. """ cmonger = services.knownservices.certmonger cmonger.enable() services.knownservices.dbus.start() cmonger.start() bus = dbus.SystemBus() obj = bus.get_object('org.fedorahosted.certmonger', '/org/fedorahosted/certmonger') iface = dbus.Interface(obj, 'org.fedorahosted.certmonger') for suffix, args in [('', ''), ('-reuse', ' --reuse-existing')]: name = 'dogtag-ipa-ca-renew-agent' + suffix path = iface.find_ca_by_nickname(name) if not path: command = paths.DOGTAG_IPA_CA_RENEW_AGENT_SUBMIT + args iface.add_known_ca( name, command, dbus.Array([], dbus.Signature('s')), # Give dogtag extra time to generate cert timeout=CA_DBUS_TIMEOUT)
def test_40_create_read_only(self): opts = dbus.Dictionary({"read-only": dbus.Boolean(True)}, signature=dbus.Signature('sv')) with open(self.LOOP_DEVICE_FILENAME, "r+b") as loop_file: fd = loop_file.fileno() loop_dev_obj_path = self.manager.LoopSetup(fd, opts) self.assertTrue(loop_dev_obj_path) self.assertTrue(loop_dev_obj_path.startswith(self.path_prefix)) path, loop_dev = loop_dev_obj_path.rsplit("/", 1) self.addCleanup(self.run_command, "losetup -d /dev/%s" % loop_dev) loop_dev_obj = self.get_object(loop_dev_obj_path) # should use the right backing file raw = self.get_property(loop_dev_obj, '.Loop', 'BackingFile') # transcription to array of Bytes to string plus adding the trailing \0 backing_file = self.str_to_ay( os.path.join(os.getcwd(), self.LOOP_DEVICE_FILENAME)) raw.assertEqual(backing_file) # should use the whole file size = self.get_property(loop_dev_obj, ".Block", "Size") size.assertEqual(10 * 1024**2) # should be read-only ro = self.get_property(loop_dev_obj, ".Block", "ReadOnly") ro.assertTrue()
def _b64_string_to_dbus_byte_array(b64_string): """Base64 decodes a dbus byte array for use with the xml rpc proxy.""" dbus_array = dbus.Array([], signature=dbus.Signature('y')) bytes = bytearray(base64.standard_b64decode(b64_string)) for byte in bytes: dbus_array.append(dbus.Byte(byte)) return dbus_array
def test_30_create_with_offset_size(self): opts = dbus.Dictionary( { "offset": dbus.UInt64(4096), "size": dbus.UInt64(4 * 1024**2) }, signature=dbus.Signature('sv')) with open(self.LOOP_DEVICE_FILENAME, "r+b") as loop_file: fd = loop_file.fileno() loop_dev_obj_path = self.manager.LoopSetup(fd, opts) self.assertTrue(loop_dev_obj_path) self.assertTrue(loop_dev_obj_path.startswith(self.path_prefix)) path, loop_dev = loop_dev_obj_path.rsplit("/", 1) self.addCleanup(self.run_command, "losetup -d /dev/%s" % loop_dev) loop_dev_obj = self.get_object(loop_dev_obj_path) # should use the right backing file raw = self.get_property(loop_dev_obj, '.Loop', 'BackingFile') # transcription to array of Bytes to string plus adding the trailing \0 backing_file = self.str_to_ay( os.path.join(os.getcwd(), self.LOOP_DEVICE_FILENAME)) raw.assertEqual(backing_file) # should use just the space specified by the 'size' argument size = self.get_property(loop_dev_obj, ".Block", "Size") size.assertEqual(4 * 1024**2) # should be writable ro = self.get_property(loop_dev_obj, ".Block", "ReadOnly") ro.assertFalse()
def __init__(self): gobject.GObject.__init__(self) self.name = "" ###settings name### self.prop_dict = dbus.Dictionary(signature=dbus.Signature( 'sv')) ##{name:value} inited in nm_remote_connection### self.prop_flags = {} ###name:flags### self.prop_list = []
def set_volume(dev, volume): ''' get device volume @param dev: a device path @param volume: a int type ''' volumes_list = [volume] * PA_CHANNELS[dev]["channel_num"] PA_DEVICE[dev].set_volume(dbus.Array(volumes_list, signature=dbus.Signature('u')))
def str_to_ay(self, string): """Convert a string to a bytearray (terminated with '\0')""" string += '\0' return dbus.Array([dbus.Byte(ord(c)) for c in string], signature=dbus.Signature('y'), variant_level=1)
def Get(self, interface, property): tracing.log.debug("Get %s %s %s" % (self._objectPath, interface, property)) value = dbus.Array([], signature=dbus.Signature('i'), variant_level=1) if interface == InterfaceBusItem: if property in self._properties: value = self._properties[property] return value