Skip to content

Commit 27d7338

Browse files
committed
Adding absolute imports for python2 compatiblity
1 parent c5d9ba4 commit 27d7338

File tree

7 files changed

+33
-1
lines changed

7 files changed

+33
-1
lines changed

rawsocketpy/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
.. moduleauthor:: Alexis Paques <[email protected]>
99
"""
1010

11+
from __future__ import absolute_import
1112
from __future__ import print_function
1213
try:
1314
from gevent import monkey; monkey.patch_all()

rawsocketpy/asyncserver.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
from __future__ import absolute_import
45
from .server import RawServer, RawServerCallback
56
from gevent import pool, Greenlet
67

rawsocketpy/packet.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
from __future__ import absolute_import
45
from .util import to_str, to_bytes
56

67
class RawPacket():

rawsocketpy/server.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
from __future__ import absolute_import
45
from .packet import RawPacket
56
from .socket import RawSocket
67
from .util import get_hw, to_bytes, protocol_to_ethertype

rawsocketpy/socket.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
from __future__ import absolute_import
45
import socket, select, struct, time
56
from .packet import RawPacket
67
from .util import get_hw, to_str, protocol_to_ethertype, to_bytes

rawsocketpy/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
from __future__ import print_function
4+
from __future__ import absolute_import
55
import socket
66
import fcntl
77
import struct

test.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
from rawsocketpy import RawRequestHandler, RawAsyncServerCallback
3+
import time
4+
5+
def callback(handler, server):
6+
print("Testing")
7+
handler.setup()
8+
handler.handle()
9+
handler.finish()
10+
11+
class LongTaskTest(RawRequestHandler):
12+
def handle(self):
13+
time.sleep(1)
14+
print(self.packet)
15+
16+
def finish(self):
17+
print("End")
18+
19+
def setup(self):
20+
print("Begin")
21+
22+
def main():
23+
rs = RawAsyncServerCallback("wlp2s0", 0xEEFA, LongTaskTest, callback)
24+
rs.spin()
25+
26+
if __name__ == '__main__':
27+
main()

0 commit comments

Comments
 (0)