3 # wpa_supplicant/hostapd control interface using Python
4 # Copyright (c) 2013, Jouni Malinen <j@w1.fi>
6 # This software may be distributed under the terms of the BSD license.
7 # See README for more details.
16 def __init__(self, path):
20 self.s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
22 self.local = "/tmp/wpa_ctrl_" + str(os.getpid()) + '-' + str(counter)
24 self.s.bind(self.local)
25 self.s.connect(self.dest)
39 def request(self, cmd):
41 [r, w, e] = select.select([self.s], [], [], 10)
43 return self.s.recv(4096)
44 raise Exception("Timeout on waiting response")
49 res = self.request("ATTACH")
52 raise Exception("ATTACH failed")
57 res = self.request("DETACH")
60 raise Exception("DETACH failed")
63 [r, w, e] = select.select([self.s], [], [], 0)
69 res = self.s.recv(4096)