Test for MKD / RMD works like a charm
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DESKTOP-DPA61F8\Benedek 2021-04-26 14:40:32 +02:00
parent 3e0afb0d45
commit b08da25d21
3 changed files with 13 additions and 6 deletions

View File

@ -76,6 +76,7 @@ class Authetication:
shutil.rmtree(self.HOME_DIRECTORY_LOCATION)
os.mkdir(self.HOME_DIRECTORY_LOCATION)
os.mkdir(self.HOME_DIRECTORY_LOCATION + os.path.sep + '0')
shutil.rmtree(self.PRIVATE_KEY_DIRECTORY_LOCATION)
os.mkdir(self.PRIVATE_KEY_DIRECTORY_LOCATION)

View File

@ -2,17 +2,23 @@
import os
import re
import sys
class Executor:
"""This class executes commands recieved by the server"""
ABSOLUTE_PATH = os.path.abspath(os.path.dirname(sys.argv[0]))
BASE_PATH = ABSOLUTE_PATH + os.path.sep + 'home' + os.path.sep
DEFAULT_FOLDER = BASE_PATH + '0'
def __init__(self, currentDiectory: str, baseDir: str = ""):
self.currentDirectory = currentDiectory
if baseDir == "":
self.baseDir = self.currentDirectory
self.baseDir = self.DEFAULT_FOLDER
else:
self.baseDir = baseDir
self.baseDir = self.BASE_PATH + baseDir + os.path.sep
def sanitizeDirectory(self, inDirectory: str) -> str:
return re.sub('[^a-zA-Z0-9]', '', inDirectory)
@ -22,13 +28,13 @@ class Executor:
def createDirectory(self, dirName: str) -> str:
dirName = self.sanitizeDirectory(dirName)
actualDirName = os.path.join(self.currentDirectory, dirName)
actualDirName: str = os.path.join(self.baseDir,self.currentDirectory,dirName)
os.mkdir(actualDirName)
return actualDirName
def removeDirectory(self, dirName: str) -> str:
dirName = self.sanitizeDirectory(dirName)
actualDirName = os.path.join(self.currentDirectory, dirName)
actualDirName: str = os.path.join(self.baseDir, self.currentDirectory, dirName)
if actualDirName:
os.rmdir(actualDirName)
return actualDirName

View File

@ -21,13 +21,13 @@ class Server:
def login(self, homeDir: str) -> None:
self.isAuthenticated = True
self.executor.baseDir = Executor(homeDir)
self.executor = Executor("", homeDir)
def logout(self) -> None:
self.networkInstance.logout()
self.isAuthenticated = False
self.availableServer = False
self.executor.baseDir = Executor("")
self.executor = Executor("")
def parseCommand(self, command: str) -> None:
if command == "LINOK":