From 5a50fdc655c6d71964bba646d2b8564228133a03 Mon Sep 17 00:00:00 2001
From: Jannis Konrad <kabel42@gmail.com>
Date: Wed, 3 May 2017 11:23:38 +0200
Subject: [PATCH] move everything into a module

---
 .gitmodules                               |  2 +-
 DTLSSocket.py => DTLSSocket/DTLSSocket.py |  6 +++---
 {lowlevel => DTLSSocket}/dtls.pyx         |  0
 {lowlevel => DTLSSocket}/tdtls.pxd        |  0
 {lowlevel => DTLSSocket}/tinydtls         |  0
 setup.py                                  | 16 ++++++++--------
 6 files changed, 12 insertions(+), 12 deletions(-)
 rename DTLSSocket.py => DTLSSocket/DTLSSocket.py (97%)
 rename {lowlevel => DTLSSocket}/dtls.pyx (100%)
 rename {lowlevel => DTLSSocket}/tdtls.pxd (100%)
 rename {lowlevel => DTLSSocket}/tinydtls (100%)

diff --git a/.gitmodules b/.gitmodules
index d188ca5..a18b9eb 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
 [submodule "tinydtls"]
-	path = lowlevel/tinydtls
+	path = DTLSSocket/tinydtls
 	url = https://git.eclipse.org/r/tinydtls/org.eclipse.tinydtls
diff --git a/DTLSSocket.py b/DTLSSocket/DTLSSocket.py
similarity index 97%
rename from DTLSSocket.py
rename to DTLSSocket/DTLSSocket.py
index c0525b2..738af00 100644
--- a/DTLSSocket.py
+++ b/DTLSSocket/DTLSSocket.py
@@ -1,5 +1,5 @@
 import socket, time
-import lowlevel.dtls as dtls
+from . import dtls
 
 DTLS_CLIENT = dtls.DTLS_CLIENT
 DTLS_SERVER = dtls.DTLS_SERVER
@@ -16,7 +16,7 @@ class DTLSSocket():
     self._sock = socket.socket(family=socket.AF_INET6, type=socket.SOCK_DGRAM)
     self._sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVPKTINFO, 1)
     self.d = dtls.DTLS(read=self._read, write=self._write, event=self._event, pskId=pskId, pskStore=pskStore)
-    self.d.setLogLevel(logLevel)
+    dtls.setLogLevel(logLevel)
     #print("Init done:", self._sock, self.d)
   
   def __del__(self):
@@ -66,7 +66,7 @@ class DTLSSocket():
         print("unknown MC", address, "not in", self.connected)
         return 0 #Not Client in MC-Group, aiocoap wantes to answer MC-PUT?
       
-      print("connecting...", address)
+      #print("connecting...", address)
       timeout = self.gettimeout()
       self.settimeout(1.0)
       
diff --git a/lowlevel/dtls.pyx b/DTLSSocket/dtls.pyx
similarity index 100%
rename from lowlevel/dtls.pyx
rename to DTLSSocket/dtls.pyx
diff --git a/lowlevel/tdtls.pxd b/DTLSSocket/tdtls.pxd
similarity index 100%
rename from lowlevel/tdtls.pxd
rename to DTLSSocket/tdtls.pxd
diff --git a/lowlevel/tinydtls b/DTLSSocket/tinydtls
similarity index 100%
rename from lowlevel/tinydtls
rename to DTLSSocket/tinydtls
diff --git a/setup.py b/setup.py
index f644a6b..6b7983a 100644
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@ class prepare_tinydtls(build_ext):
     def run(self):
         def run_command(args):
             print("Running:", " ".join(args))
-            subprocess.check_call(args, cwd="./lowlevel/tinydtls")
+            subprocess.check_call(args, cwd="./DTLSSocket/tinydtls")
         commands = [
             ["autoconf"],
             ["autoheader"],
@@ -20,13 +20,13 @@ class prepare_tinydtls(build_ext):
         build_ext.run(self)
 
 cy_build = cythonize([
-      Extension("lowlevel.dtls",
-                ["lowlevel/dtls.pyx", "lowlevel/tinydtls/dtls.c", "lowlevel/tinydtls/crypto.c",
-                 "lowlevel/tinydtls/ccm.c", "lowlevel/tinydtls/hmac.c", "lowlevel/tinydtls/netq.c",
-                 "lowlevel/tinydtls/peer.c", "lowlevel/tinydtls/dtls_time.c",
-                 "lowlevel/tinydtls/session.c", "lowlevel/tinydtls/dtls_debug.c",
-                 "lowlevel/tinydtls/aes/rijndael.c", "lowlevel/tinydtls/sha2/sha2.c"],
-                include_dirs=['lowlevel/tinydtls'],
+      Extension("DTLSSocket.dtls",
+                ["DTLSSocket/dtls.pyx", "DTLSSocket/tinydtls/dtls.c", "DTLSSocket/tinydtls/crypto.c",
+                 "DTLSSocket/tinydtls/ccm.c", "DTLSSocket/tinydtls/hmac.c", "DTLSSocket/tinydtls/netq.c",
+                 "DTLSSocket/tinydtls/peer.c", "DTLSSocket/tinydtls/dtls_time.c",
+                 "DTLSSocket/tinydtls/session.c", "DTLSSocket/tinydtls/dtls_debug.c",
+                 "DTLSSocket/tinydtls/aes/rijndael.c", "DTLSSocket/tinydtls/sha2/sha2.c"],
+                include_dirs=['DTLSSocket/tinydtls'],
                 define_macros=[('DTLSv12', '1'),
                                ('WITH_SHA256', '1'),
                                ('DTLS_CHECK_CONTENTTYPE', '1'),
-- 
GitLab