aboutsummaryrefslogtreecommitdiffstats
path: root/test/functional/util/dummy_p0f.py
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2020-06-25 21:34:48 +0200
committerAndrew Lewis <nerf@judo.za.org>2020-06-25 21:34:48 +0200
commitaa3d11920940f91b9677a802e4cca8775939376f (patch)
tree9f53bfec6196bed234b6436d5967e2455d44bc6c /test/functional/util/dummy_p0f.py
parentc31bf17fc483952e01468c7ff0f70b9ec0b8ad1d (diff)
downloadrspamd-aa3d11920940f91b9677a802e4cca8775939376f.tar.gz
rspamd-aa3d11920940f91b9677a802e4cca8775939376f.zip
[Test] Use Python3 for functional tests
- Fix more deprecated Robot Framework syntax - Remove log following - Remove some artefacts in teardown - Restore use of demjson
Diffstat (limited to 'test/functional/util/dummy_p0f.py')
-rwxr-xr-xtest/functional/util/dummy_p0f.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/test/functional/util/dummy_p0f.py b/test/functional/util/dummy_p0f.py
index d780bdb0d..2bcd183d4 100755
--- a/test/functional/util/dummy_p0f.py
+++ b/test/functional/util/dummy_p0f.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
PID = "/tmp/dummy_p0f.pid"
@@ -6,11 +6,9 @@ import os
import sys
import struct
import socket
+import socketserver
+
import dummy_killer
-try:
- import SocketServer as socketserver
-except:
- import socketserver
class MyStreamHandler(socketserver.BaseRequestHandler):
@@ -22,8 +20,8 @@ class MyStreamHandler(socketserver.BaseRequestHandler):
}
OS = {
- 'windows' : ('Windows', '7 or 8'),
- 'linux' : ('Linux', '3.11 and newer')
+ 'windows' : (b'Windows', b'7 or 8'),
+ 'linux' : (b'Linux', b'3.11 and newer')
}
self.data = self.request.recv(21).strip()
@@ -47,10 +45,10 @@ class MyStreamHandler(socketserver.BaseRequestHandler):
0, # os_match_q
OS[self.server.p0f_os][0], # os_name
OS[self.server.p0f_os][1], # os_flavor
- '', # http_name
- '', # http_flavor
- 'Ethernet or modem', # link_type
- '' # language
+ b'', # http_name
+ b'', # http_flavor
+ b'Ethernet or modem', # link_type
+ b'' # language
)
self.request.sendall(response)
@@ -61,7 +59,7 @@ def cleanup(SOCK):
try:
os.unlink(SOCK)
except OSError:
- print "Could not unlink socket: " + SOCK
+ print("Could not unlink socket: " + SOCK)
if __name__ == "__main__":
SOCK = '/tmp/p0f.sock'
@@ -92,7 +90,7 @@ if __name__ == "__main__":
try:
server.handle_request()
except socket.error:
- print "Socket closed"
+ print("Socket closed")
server.server_close()
cleanup(SOCK)