Test for MKD / RMD works like a charm
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
3e0afb0d45
commit
b08da25d21
@ -76,6 +76,7 @@ class Authetication:
|
|||||||
|
|
||||||
shutil.rmtree(self.HOME_DIRECTORY_LOCATION)
|
shutil.rmtree(self.HOME_DIRECTORY_LOCATION)
|
||||||
os.mkdir(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)
|
shutil.rmtree(self.PRIVATE_KEY_DIRECTORY_LOCATION)
|
||||||
os.mkdir(self.PRIVATE_KEY_DIRECTORY_LOCATION)
|
os.mkdir(self.PRIVATE_KEY_DIRECTORY_LOCATION)
|
||||||
|
|
||||||
|
@ -2,17 +2,23 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class Executor:
|
class Executor:
|
||||||
"""This class executes commands recieved by the server"""
|
"""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 = ""):
|
def __init__(self, currentDiectory: str, baseDir: str = ""):
|
||||||
self.currentDirectory = currentDiectory
|
self.currentDirectory = currentDiectory
|
||||||
if baseDir == "":
|
if baseDir == "":
|
||||||
self.baseDir = self.currentDirectory
|
self.baseDir = self.DEFAULT_FOLDER
|
||||||
else:
|
else:
|
||||||
self.baseDir = baseDir
|
self.baseDir = self.BASE_PATH + baseDir + os.path.sep
|
||||||
|
|
||||||
|
|
||||||
def sanitizeDirectory(self, inDirectory: str) -> str:
|
def sanitizeDirectory(self, inDirectory: str) -> str:
|
||||||
return re.sub('[^a-zA-Z0-9]', '', inDirectory)
|
return re.sub('[^a-zA-Z0-9]', '', inDirectory)
|
||||||
@ -22,13 +28,13 @@ class Executor:
|
|||||||
|
|
||||||
def createDirectory(self, dirName: str) -> str:
|
def createDirectory(self, dirName: str) -> str:
|
||||||
dirName = self.sanitizeDirectory(dirName)
|
dirName = self.sanitizeDirectory(dirName)
|
||||||
actualDirName = os.path.join(self.currentDirectory, dirName)
|
actualDirName: str = os.path.join(self.baseDir,self.currentDirectory,dirName)
|
||||||
os.mkdir(actualDirName)
|
os.mkdir(actualDirName)
|
||||||
return actualDirName
|
return actualDirName
|
||||||
|
|
||||||
def removeDirectory(self, dirName: str) -> str:
|
def removeDirectory(self, dirName: str) -> str:
|
||||||
dirName = self.sanitizeDirectory(dirName)
|
dirName = self.sanitizeDirectory(dirName)
|
||||||
actualDirName = os.path.join(self.currentDirectory, dirName)
|
actualDirName: str = os.path.join(self.baseDir, self.currentDirectory, dirName)
|
||||||
if actualDirName:
|
if actualDirName:
|
||||||
os.rmdir(actualDirName)
|
os.rmdir(actualDirName)
|
||||||
return actualDirName
|
return actualDirName
|
||||||
|
@ -21,13 +21,13 @@ class Server:
|
|||||||
|
|
||||||
def login(self, homeDir: str) -> None:
|
def login(self, homeDir: str) -> None:
|
||||||
self.isAuthenticated = True
|
self.isAuthenticated = True
|
||||||
self.executor.baseDir = Executor(homeDir)
|
self.executor = Executor("", homeDir)
|
||||||
|
|
||||||
def logout(self) -> None:
|
def logout(self) -> None:
|
||||||
self.networkInstance.logout()
|
self.networkInstance.logout()
|
||||||
self.isAuthenticated = False
|
self.isAuthenticated = False
|
||||||
self.availableServer = False
|
self.availableServer = False
|
||||||
self.executor.baseDir = Executor("")
|
self.executor = Executor("")
|
||||||
|
|
||||||
def parseCommand(self, command: str) -> None:
|
def parseCommand(self, command: str) -> None:
|
||||||
if command == "LINOK":
|
if command == "LINOK":
|
||||||
|
Loading…
Reference in New Issue
Block a user