no return, send message
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
4bd161de54
commit
a5490854af
@ -35,14 +35,14 @@ class Server:
|
|||||||
self.homeDirectory = ""
|
self.homeDirectory = ""
|
||||||
self.executor.baseDir = Executor(self.homeDirectory)
|
self.executor.baseDir = Executor(self.homeDirectory)
|
||||||
|
|
||||||
def parseCommand(self, command: str) -> str:
|
def parseCommand(self, command: str) -> None:
|
||||||
if command == "LINOK":
|
if command == "LINOK":
|
||||||
return "LINOK"
|
self.networkInstance.sendMessage("LINOK".encode('UTF-8'))
|
||||||
elif command == "LINERROR":
|
elif command == "LINERROR":
|
||||||
return "LINERROR"
|
self.networkInstance.sendMessage("LINERROR".encode('UTF-8'))
|
||||||
parsedCommand = command.split(" ")
|
parsedCommand = command.split(" ")
|
||||||
if len(parsedCommand) > 3:
|
if len(parsedCommand) > 3:
|
||||||
return "ERROR"
|
self.networkInstance.sendMessage("ERROR".encode('UTF-8'))
|
||||||
# TODO: Ez igy gecironda, ezt meg kene csinalni rendesen.
|
# TODO: Ez igy gecironda, ezt meg kene csinalni rendesen.
|
||||||
elif len(parsedCommand) == 1:
|
elif len(parsedCommand) == 1:
|
||||||
return self.execute(parsedCommand[0])
|
return self.execute(parsedCommand[0])
|
||||||
@ -51,42 +51,48 @@ class Server:
|
|||||||
elif len(parsedCommand) == 3:
|
elif len(parsedCommand) == 3:
|
||||||
return self.execute(parsedCommand[0], parsedCommand[1], parsedCommand[2])
|
return self.execute(parsedCommand[0], parsedCommand[1], parsedCommand[2])
|
||||||
|
|
||||||
def execute(self, command: str, firstParam: str = "", secondParam: str = "") -> str:
|
def execute(self, command: str, firstParam: str = "", secondParam: str = "") -> None:
|
||||||
if self.homeDirectory == "" or self.executor.currentDirectory == "" or self.executor.baseDir == "":
|
if self.homeDirectory == "" or self.executor.currentDirectory == "" or self.executor.baseDir == "":
|
||||||
raise Exception("Directories must not be empty string. Did the user log in?")
|
raise Exception("Directories must not be empty string. Did the user log in?")
|
||||||
if command == "MKD":
|
if command == "MKD":
|
||||||
if secondParam != "":
|
if secondParam != "":
|
||||||
return "ERROR"
|
self.networkInstance.sendMessage("ERROR".encode('UTF-8'))
|
||||||
else:
|
else:
|
||||||
return self.executor.createDirectory(firstParam)
|
self.executor.createDirectory(firstParam)
|
||||||
|
self.networkInstance.sendMessage("OK".encode('UTF-8'))
|
||||||
elif command == "RMD":
|
elif command == "RMD":
|
||||||
if secondParam != "":
|
if secondParam != "":
|
||||||
return "ERROR"
|
self.networkInstance.sendMessage("ERROR".encode('UTF-8'))
|
||||||
else:
|
else:
|
||||||
return self.executor.removeDirectory(firstParam)
|
self.executor.removeDirectory(firstParam)
|
||||||
|
self.networkInstance.sendMessage("OK".encode('UTF-8'))
|
||||||
elif command == "GWD":
|
elif command == "GWD":
|
||||||
if secondParam != "" or firstParam != "":
|
if secondParam != "" or firstParam != "":
|
||||||
return "ERROR"
|
self.networkInstance.sendMessage("ERROR".encode('UTF-8'))
|
||||||
else:
|
else:
|
||||||
return self.executor.getCurrentDirectory()
|
self.executor.getCurrentDirectory()
|
||||||
|
self.networkInstance.sendMessage("OK".encode('UTF-8'))
|
||||||
elif command == "CWD":
|
elif command == "CWD":
|
||||||
if secondParam != "":
|
if secondParam != "":
|
||||||
return "ERROR"
|
self.networkInstance.sendMessage("ERROR".encode('UTF-8'))
|
||||||
else:
|
else:
|
||||||
return self.executor.setCurrentDirectory(firstParam)
|
self.executor.setCurrentDirectory(firstParam)
|
||||||
|
self.networkInstance.sendMessage("OK".encode('UTF-8'))
|
||||||
elif command == "LST":
|
elif command == "LST":
|
||||||
if secondParam != "" or firstParam != "":
|
if secondParam != "" or firstParam != "":
|
||||||
return "ERROR"
|
self.networkInstance.sendMessage("ERROR".encode('UTF-8'))
|
||||||
else:
|
else:
|
||||||
return self.executor.listCurrentDirectoryContent()
|
self.executor.listCurrentDirectoryContent()
|
||||||
|
self.networkInstance.sendMessage("OK".encode('UTF-8'))
|
||||||
elif command == "RMF":
|
elif command == "RMF":
|
||||||
if secondParam != "":
|
if secondParam != "":
|
||||||
return "ERROR"
|
self.networkInstance.sendMessage("ERROR".encode('UTF-8'))
|
||||||
else:
|
else:
|
||||||
return self.executor.removeFileInCurrentDirectory(firstParam)
|
self.executor.removeFileInCurrentDirectory(firstParam)
|
||||||
|
self.networkInstance.sendMessage("OK".encode('UTF-8'))
|
||||||
elif command == "UPL":
|
elif command == "UPL":
|
||||||
if secondParam != "":
|
if secondParam != "":
|
||||||
return "ERROR"
|
self.networkInstance.sendMessage("ERROR".encode('UTF-8'))
|
||||||
else:
|
else:
|
||||||
# TODO
|
# TODO
|
||||||
# Megkapod a filenevet argumentumneknt
|
# Megkapod a filenevet argumentumneknt
|
||||||
@ -97,7 +103,7 @@ class Server:
|
|||||||
pass
|
pass
|
||||||
elif command == "DNL":
|
elif command == "DNL":
|
||||||
if secondParam != "":
|
if secondParam != "":
|
||||||
return "ERROR"
|
self.networkInstance.sendMessage("ERROR".encode('UTF-8'))
|
||||||
else:
|
else:
|
||||||
# TODO
|
# TODO
|
||||||
# Megkapod a filenevet arguemntumkent
|
# Megkapod a filenevet arguemntumkent
|
||||||
@ -107,7 +113,7 @@ class Server:
|
|||||||
# Ha sikeres, OK valaszt megkapod, kulonben ERROR valaszt megkapod
|
# Ha sikeres, OK valaszt megkapod, kulonben ERROR valaszt megkapod
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
return "ERROR"
|
self.networkInstance.sendMessage("ERROR".encode('UTF-8'))
|
||||||
|
|
||||||
def startServer(self):
|
def startServer(self):
|
||||||
while True:
|
while True:
|
||||||
|
Loading…
Reference in New Issue
Block a user