+++ /dev/null
-#!/usr/bin/python
-
-import sys
-import dbus
-
-bus = dbus.SystemBus()
-
-manager = dbus.Interface(bus.get_object("net.connman", "/"),
- "net.connman.Manager")
-
-if len(sys.argv) < 2:
- print "Usage: %s <command>" % (sys.argv[0])
- print ""
- print " list"
- print " name <profile> [name]"
- print ""
- print " create <profile> [name]"
- print " remove <profile>"
- sys.exit(1)
-
-def print_profiles(profiles, active):
- for path in profiles:
- profile = dbus.Interface(bus.get_object("net.connman", path),
- "net.connman.Profile")
-
- properties = profile.GetProperties()
-
- identifier = path[path.rfind("/") + 1:]
-
- if (path == active):
- default = "*"
- else:
- default = " "
-
- if "Name" in properties.keys():
- name = properties["Name"]
- else:
- name = "<unnamed>"
-
- print "%s %-12s %s" % (default, identifier, name)
-
-if sys.argv[1] in ["list", "show"]:
- properties = manager.GetProperties()
-
- print_profiles(properties["Profiles"], properties["ActiveProfile"])
-
-elif sys.argv[1] in ["name"]:
- if (len(sys.argv) < 3):
- print "Need at least profile parameter"
- sys.exit(1)
-
- path = "/profile/" + sys.argv[2]
-
- profile = dbus.Interface(bus.get_object("net.connman", path),
- "net.connman.Profile")
-
- if (len(sys.argv) > 3):
- name = sys.argv[3]
-
- profile.SetProperty("Name", name);
-
- print "Name \"%s\" set for %s" % (name, sys.argv[2])
- else:
- properties = profile.GetProperties()
-
- if "Name" in properties.keys():
- name = "\"" + properties["Name"] + "\""
- else:
- name = "<unnamed>"
-
- print "Name for %s is %s" % (sys.argv[2], name)
-
-elif sys.argv[1] in ["create", "add"]:
- if (len(sys.argv) < 3):
- print "Profile parameter required"
- sys.exit(1)
-
- path = manager.CreateProfile(sys.argv[2])
-
- print "New profile created at %s" % (path)
-
- profile = dbus.Interface(bus.get_object("net.connman", path),
- "net.connman.Profile")
-
- if (len(sys.argv) > 3):
- name = sys.argv[3]
-
- profile.SetProperty("Name", name);
-
- print "Name \"%s\" set for %s" % (name, sys.argv[2])
-
-elif sys.argv[1] in ["remove", "delete", "del"]:
- if (len(sys.argv) < 3):
- print "Profile parameter required"
- sys.exit(1)
-
- path = "/profile/" + sys.argv[2]
-
- manager.RemoveProfile(path)
-
-else:
- print "Unknown command"