diff options
author | Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com> | 2012-05-02 16:46:11 +0300 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-05-04 11:10:32 +0300 |
commit | e0eba0a195301079f821775bddff1e0144effb03 (patch) | |
tree | 7ef6f417012f0a7e5004c9feeefa9d2d3067cd16 /test/simple-agent | |
parent | c4abb85bde08d5ed68c9cc608225e95415887d7d (diff) | |
download | connman-e0eba0a195301079f821775bddff1e0144effb03.tar.gz connman-e0eba0a195301079f821775bddff1e0144effb03.tar.bz2 connman-e0eba0a195301079f821775bddff1e0144effb03.zip |
test: Handling properly Canceled or LaunchBrowser errors
Diffstat (limited to 'test/simple-agent')
-rwxr-xr-x | test/simple-agent | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/simple-agent b/test/simple-agent index 7b0f5aa6..45437df8 100755 --- a/test/simple-agent +++ b/test/simple-agent @@ -10,6 +10,9 @@ import sys class Canceled(dbus.DBusException): _dbus_error_name = "net.connman.Error.Canceled" +class LaunchBrowser(dbus.DBusException): + _dbus_error_name = "net.connman.Agent.Error.LaunchBrowser" + class Agent(dbus.service.Object): name = None ssid = None @@ -29,9 +32,12 @@ class Agent(dbus.service.Object): response = {} if not self.identity and not self.passphrase and not self.wpspin: + print "Service credentials requested, type cancel to cancel" args = raw_input('Answer: ') for arg in args.split(): + if arg.startswith("cancel"): + response["Error"] = arg if arg.startswith("Identity="): identity = arg.replace("Identity=", "", 1) response["Identity"] = identity @@ -56,9 +62,13 @@ class Agent(dbus.service.Object): response = {} if not self.username and not self.password: + print "User login requested, type cancel to cancel" + print "or browser to login through the browser by yourself." args = raw_input('Answer: ') for arg in args.split(): + if arg.startswith("cancel") or arg.startswith("browser"): + response["Error"] = arg if arg.startswith("Username="): username = arg.replace("Username=", "", 1) response["Username"] = username @@ -111,6 +121,14 @@ class Agent(dbus.service.Object): if fields.has_key("Username"): response.update(self.input_username()) + if response.has_key("Error"): + if response["Error"] == "cancel": + raise Canceled("canceled") + return + if response["Error"] == "browser": + raise LaunchBrowser("launch browser") + return + print "returning (%s)" % (response) return response |