Update wpaspy.py to be python3 compatible
Make minor changes to wpaspy module that enables it to run in either python2 or python3. Signed-off-by: Preston Hunt <preston.hunt@intel.com>
This commit is contained in:
parent
4d6e79f867
commit
945604a355
1 changed files with 6 additions and 4 deletions
|
@ -6,6 +6,8 @@
|
||||||
# This software may be distributed under the terms of the BSD license.
|
# This software may be distributed under the terms of the BSD license.
|
||||||
# See README for more details.
|
# See README for more details.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
import socket
|
import socket
|
||||||
|
@ -38,7 +40,7 @@ class Ctrl:
|
||||||
self.s.bind(self.local)
|
self.s.bind(self.local)
|
||||||
try:
|
try:
|
||||||
self.s.connect(self.dest)
|
self.s.connect(self.dest)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.s.close()
|
self.s.close()
|
||||||
os.unlink(self.local)
|
os.unlink(self.local)
|
||||||
raise
|
raise
|
||||||
|
@ -57,7 +59,7 @@ class Ctrl:
|
||||||
self.cookie = reply
|
self.cookie = reply
|
||||||
self.port = port
|
self.port = port
|
||||||
except:
|
except:
|
||||||
print "connect exception ", path, str(port)
|
print("connect exception ", path, str(port))
|
||||||
if self.s != None:
|
if self.s != None:
|
||||||
self.s.close()
|
self.s.close()
|
||||||
raise
|
raise
|
||||||
|
@ -70,7 +72,7 @@ class Ctrl:
|
||||||
if self.attached:
|
if self.attached:
|
||||||
try:
|
try:
|
||||||
self.detach()
|
self.detach()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
# Need to ignore this allow the socket to be closed
|
# Need to ignore this allow the socket to be closed
|
||||||
self.attached = False
|
self.attached = False
|
||||||
pass
|
pass
|
||||||
|
@ -114,7 +116,7 @@ class Ctrl:
|
||||||
if self.attached:
|
if self.attached:
|
||||||
try:
|
try:
|
||||||
self.detach()
|
self.detach()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
# Need to ignore this to allow the socket to be closed
|
# Need to ignore this to allow the socket to be closed
|
||||||
self.attached = False
|
self.attached = False
|
||||||
self.request("TERMINATE")
|
self.request("TERMINATE")
|
||||||
|
|
Loading…
Reference in a new issue