finish netwrapper of server and executor improvements
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:
@@ -29,7 +29,8 @@ class Executor:
|
||||
def removeDirectory(self, dirName: str) -> str:
|
||||
dirName = self.sanitizeDirectory(dirName)
|
||||
actualDirName = os.path.join(self.currentDirectory, dirName)
|
||||
os.rmdir(actualDirName)
|
||||
if actualDirName:
|
||||
os.rmdir(actualDirName)
|
||||
return actualDirName
|
||||
|
||||
def getCurrentDirectory(self) -> str:
|
||||
@@ -40,16 +41,19 @@ class Executor:
|
||||
if self.currentDirectory == self.baseDir:
|
||||
return self.currentDirectory
|
||||
else:
|
||||
directories = self.currentDirectory.split("/")
|
||||
directories = self.currentDirectory.split(os.path.sep)
|
||||
strdirectory = ""
|
||||
for dir in directories:
|
||||
strdirectory += dir + "/"
|
||||
strdirectory += dir + os.path.sep
|
||||
strdirectory = strdirectory[:-3]
|
||||
self.currentDirectory = strdirectory
|
||||
if os.path.exists(strdirectory):
|
||||
self.currentDirectory = strdirectory
|
||||
return self.currentDirectory
|
||||
else:
|
||||
dirName = self.sanitizeDirectory(dirName)
|
||||
self.currentDirectory = os.path.join(self.currentDirectory, dirName)
|
||||
joinedDir = os.path.join(self.currentDirectory, dirName)
|
||||
if os.path.exists(joinedDir):
|
||||
self.currentDirectory = joinedDir
|
||||
return self.currentDirectory
|
||||
|
||||
def listCurrentDirectoryContent(self) -> str:
|
||||
@@ -71,10 +75,14 @@ class Executor:
|
||||
def getFileInCurrentDirectory(self, file: str):
|
||||
file = self.sanitizeFile(file)
|
||||
currentfile = os.path.join(self.currentDirectory, file)
|
||||
return open(currentfile, "r")
|
||||
if os.path.exists(currentfile):
|
||||
return open(currentfile, "r")
|
||||
else:
|
||||
raise Exception('File not found')
|
||||
|
||||
def removeFileInCurrentDirectory(self, file: str) -> str:
|
||||
file = self.sanitizeFile(file)
|
||||
currentfile = os.path.join(self.currentDirectory, file)
|
||||
os.remove(currentfile)
|
||||
if os.path.exists(currentfile):
|
||||
os.remove(currentfile)
|
||||
return currentfile
|
||||
|
||||
Reference in New Issue
Block a user