~kvalo/connman/bug-734339

« back to all changes in this revision

Viewing changes to test/list-networks

  • Committer: Ken VanDine
  • Date: 2010-12-01 18:04:21 UTC
  • mfrom: (23.1.11 connman.u)
  • Revision ID: ken.vandine@canonical.com-20101201180421-44ibz1auwpa05l8c
Tags: 0.64-0ubuntu1
releasing version 0.64-0ubuntu1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
 
3
 
import dbus
4
 
import string
5
 
 
6
 
bus = dbus.SystemBus()
7
 
 
8
 
manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
9
 
                                        "org.moblin.connman.Manager")
10
 
 
11
 
properties = manager.GetProperties()
12
 
 
13
 
def convert_ssid(ssid_list):
14
 
        ssid = ""
15
 
        for byte in ssid_list:
16
 
                if (str(byte) in string.printable):
17
 
                        ssid = ssid + str(byte)
18
 
                else:
19
 
                        ssid = ssid + "."
20
 
        return ssid
21
 
 
22
 
for path in properties["Technologies"]:
23
 
        technology = dbus.Interface(bus.get_object("org.moblin.connman", path),
24
 
                                                "org.moblin.connman.Technology")
25
 
 
26
 
        properties = technology.GetProperties()
27
 
 
28
 
        for path in properties["Devices"]:
29
 
                device = dbus.Interface(bus.get_object("org.moblin.connman", path),
30
 
                                                        "org.moblin.connman.Device")
31
 
 
32
 
                properties = device.GetProperties()
33
 
 
34
 
                try:
35
 
                        if properties["Type"] not in ["ethernet", "wifi", "wimax",
36
 
                                                        "bluetooth", "cellular"]:
37
 
                                continue
38
 
                except:
39
 
                        continue
40
 
 
41
 
                print "[ %s ]" % (path)
42
 
 
43
 
                for path in properties["Networks"]:
44
 
                        network = dbus.Interface(bus.get_object("org.moblin.connman", path),
45
 
                                                        "org.moblin.connman.Network")
46
 
 
47
 
                        properties = network.GetProperties()
48
 
 
49
 
                        print "    [ %s ]" % (path)
50
 
 
51
 
                        for key in properties.keys():
52
 
                                if key == "WiFi.SSID":
53
 
                                        ssid = convert_ssid(properties[key])
54
 
                                        print "        %s = [ %s ]" % (key, ssid)
55
 
                                elif key in ["Strength", "Priority"]:
56
 
                                        print "        %s = %d" % (key, properties[key])
57
 
                                else:
58
 
                                        print "        %s = %s" % (key, properties[key])
59
 
 
60
 
                print