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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#!/usr/bin/python3
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 = 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",
"Features",
"AvailableTechnologies"]:
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",
"Strength",
"DataStrength",
"BatteryChargeLevel"]:
val = int(properties[key])
elif key in ["MainMenu"]:
val = ", ".join([ text + " (" + str(int(icon)) +
")" for text, icon in properties[key] ])
elif key in ["Retries"]:
val = ""
for i in properties[key]:
val += "[" + i + " = "
val += str(int(properties[key][i])) + "] "
elif key in ["Settings"]:
val = "{"
for i in properties[key].keys():
val += " " + i + "="
if i in ["DomainNameServers"]:
for n in properties[key][i]:
val += n + ","
else:
val += properties[key][i]
val += " }"
else:
val = properties[key]
print(" %s = %s" % (key, val))
print('')
|