From 4bf109a7ce52f82d21c42281407742059a41f490 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Tue, 26 May 2015 19:51:26 +0200 Subject: [PATCH] test: Avoid input() in simple-agent.py. That function reads a string of python code and immediately executes it. This required passphrases to be input as python literals, we can just use a string as passphrase instead. --- test/simple-agent | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/test/simple-agent b/test/simple-agent index f94c1572..7f088fee 100755 --- a/test/simple-agent +++ b/test/simple-agent @@ -20,42 +20,20 @@ class Agent(dbus.service.Object): print("Release") mainloop.quit() - def input_passphrase(self): - response = {} - - if not self.passphrase: - print("Service credentials requested, type cancel to cancel") - args = input('Answer: ') - - for arg in args.split(): - if arg.startswith("cancel"): - response["Error"] = arg - - if arg.startswith("Passphrase="): - passphrase = arg.replace("Passphrase=", "", 1) - response["Passphrase"] = passphrase - else: - if self.passphrase: - response["Passphrase"] = self.passphrase - - return response - @dbus.service.method("net.connman.iwd.Agent", in_signature='o', out_signature='s') def RequestPassphrase(self, path): print("RequestPassphrase (%s)" % (path)) - response = {} - response.update(self.input_passphrase()) + print("Service credentials requested, type cancel to cancel") + passphrase = raw_input('Answer: ') - if response.has_key("Error"): - if response["Error"] == "cancel": - raise Canceled("canceled") - return + if not passphrase or passphrase == 'cancel': + raise Canceled("canceled") - print("returning (%s)" % (response["Passphrase"])) - return response["Passphrase"] + print("returning (%s)" % (passphrase)) + return passphrase @dbus.service.method("net.connman.iwd.Agent", in_signature='', out_signature='')