fail better
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2021-04-26 22:56:06 +02:00
parent c4333ed827
commit 034f1e3403
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047

View File

@ -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'))