use unipath
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Torma Kristóf 2021-04-29 17:33:15 +02:00
parent 7f1a5f1013
commit 4466ee6172
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
2 changed files with 10 additions and 9 deletions

View File

@ -1,2 +1,3 @@
pycryptodome
pydh
pydh
unipath

View File

@ -3,6 +3,8 @@
import os
import re
from unipath import Path
class Executor:
"""This class executes commands recieved by the server"""
@ -34,16 +36,14 @@ class Executor:
def setCurrentDirectory(self, dirName: str) -> str:
if dirName == "..":
if self.currentDirectory == "":
p = Path(os.path.join(self.baseDir, self.currentDirectory))
parentpath = p.parent
if str(parentpath) == self.baseDir:
return self.currentDirectory
else:
directories = self.currentDirectory.split(os.path.sep)
strdirectory = ""
for dir in directories:
strdirectory = os.path.join(strdirectory, dir)
strdirectory = strdirectory[:-3]
if os.path.exists(os.path.join(self.baseDir, self.currentDirectory)):
self.currentDirectory = strdirectory
newpath = str(parentpath).replace(self.baseDir,'')
if os.path.exists(os.path.join(self.baseDir,newpath)):
self.currentDirectory = newpath
return self.currentDirectory
else:
dirName = self.sanitizeDirectory(dirName)