From 034f1e3403a5b20a7988e29c91c6386e79e02cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Mon, 26 Apr 2021 22:56:06 +0200 Subject: [PATCH] fail better --- server/server.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/server.py b/server/server.py index 792d114..ae7238d 100644 --- a/server/server.py +++ b/server/server.py @@ -51,7 +51,7 @@ class Server: if self.executor.baseDir == "": raise Exception("Home directory must not be empty string. Did the user log in?") if command == "LOUT": - if secondParam != "" or firstParam != "": + if not (secondParam == "" and firstParam == ""): self.networkInstance.sendMessage("ERROR".encode('UTF-8')) else: self.networkInstance.sendMessage("OK".encode('UTF-8')) @@ -69,7 +69,7 @@ class Server: self.executor.removeDirectory(firstParam) self.networkInstance.sendMessage("OK".encode('UTF-8')) elif command == "GWD": - if secondParam != "" or firstParam != "": + if not (secondParam == "" and firstParam == ""): self.networkInstance.sendMessage("ERROR".encode('UTF-8')) else: self.networkInstance.sendMessage(self.executor.getCurrentDirectory().encode('UTF-8')) @@ -80,7 +80,7 @@ class Server: self.executor.setCurrentDirectory(firstParam) self.networkInstance.sendMessage("OK".encode('UTF-8')) elif command == "LST": - if secondParam != "" or firstParam != "": + if not (secondParam == "" and firstParam == ""): self.networkInstance.sendMessage("ERROR".encode('UTF-8')) else: self.networkInstance.sendMessage(self.executor.listCurrentDirectoryContent().encode('UTF-8')) @@ -109,7 +109,7 @@ class Server: file = self.executor.getFileInCurrentDirectory(firstParam) self.networkInstance.sendMessage(file) self.networkInstance.sendMessage("EOF".encode('UTF-8')) - except: + except Exception: self.networkInstance.sendMessage("ERROR".encode('UTF-8')) else: self.networkInstance.sendMessage("ERROR".encode('UTF-8'))