From c091532f7477c6046080aef06db113af670ee904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Sun, 25 Apr 2021 17:35:39 +0200 Subject: [PATCH] comment pszeudoprogramming meme --- server/netwrapper.py | 6 +++--- server/server.py | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/server/netwrapper.py b/server/netwrapper.py index a000bc1..b7b38ef 100644 --- a/server/netwrapper.py +++ b/server/netwrapper.py @@ -101,13 +101,13 @@ class NetWrapper: self.keyExchange() success = self.login() if success: - return b"LINOK" + return "LINOK".encode('UTF-8') else: self.logout() - return b"LINERROR" + return "LINERROR".encode('UTF-8') except Exception: self.logout() - return b"LINERROR" + return "LINERROR".encode('UTF-8') def recieveMessage(self) -> bytes: status, msg = self.network.receive_msg(blocking=True) diff --git a/server/server.py b/server/server.py index a5b3194..a536a7d 100644 --- a/server/server.py +++ b/server/server.py @@ -31,6 +31,10 @@ class Server: self.executor.baseDir=Executor(self.homeDirectory) def parseCommand(self, command: str) -> str: + if command == "LINOK": + return "LINOK" + elif command == "LINERROR": + return "LINERROR" parsedCommand = command.split(" ") if len(parsedCommand) > 3: return "ERROR" @@ -80,18 +84,25 @@ class Server: return "ERROR" else: # TODO + # Megkapod a filenevet argumentumneknt + # Fogadni kell egy uzenetet, ami a fajl tartalma + # Fogadni kell egy uzenetet, ami "EOF" + # Mindig minden legyen UTF-8-kent kodolva, kiveve a falj, az marard pass elif command == "DNL": if secondParam != "": return "ERROR" else: # TODO + # Megkapod a filenevet arguemntumkent + # Kuldeni kell egy uzenetet, ami a falj tartalma + # Kuldeni kell egy uzenetet, ami EOF + # Mindig minden legyen UTF-8-kent kodolva, kiveve a falj, az marard pass else: return "ERROR" def startServer(self): - while (True): - self.networkInstance.recieveMessage() - - startServer() + while True: + message = self.networkInstance.recieveMessage().decode('UTF-8') + self.parseCommand(message)