summaryrefslogtreecommitdiffstats
path: root/test/list-modems
blob: 557efd526c030e2b34c1864280d340896ef74bbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/python

import dbus

bus = dbus.SystemBus()

manager = dbus.Interface(bus.get_object('org.ofono', '/'),
						'org.ofono.Manager')

modems = manager.GetModems()

for path, properties in modems:
	print "[ %s ]" % (path)

	for key in properties.keys():
		if key in ["Interfaces", "Features"]:
			val = ""
			for i in properties[key]:
				val += i + " "
		else:
			val = str(properties[key])
		print "    %s = %s" % (key, val)

	for interface in properties["Interfaces"]:
		object = dbus.Interface(bus.get_object('org.ofono', path),
								interface)

		print "    [ %s ]" % (interface)

		try:
			properties = object.GetProperties()
		except:
			continue

		for key in properties.keys():
			if key in ["Calls",
					"MultipartyCalls",
					"EmergencyNumbers",
					"SubscriberNumbers",
					"PreferredLanguages",
					"PrimaryContexts",
					"LockedPins"]:
				val = ""
				for i in properties[key]:
					val += i + " "
			elif key in ["ServiceNumbers"]:
				val = ""
				for i in properties[key]:
					val += "[" + i + "] = '"
					val += properties[key][i] + "' "
			elif key in ["MobileNetworkCodeLength",
						"VoicemailMessageCount",
						"MicrophoneVolume",
						"SpeakerVolume"]:
				val = int(properties[key])
			elif key in ["MainMenu"]:
				val = ", ".join([ text + " (" + str(int(icon)) +
					")" for text, icon in properties[key] ])
			else:
				val = str(properties[key])
			print "        %s = %s" % (key, val)

	print