Loading transfer_service/exceptions.py +8 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,14 @@ class MultipleUsersException(Error): super(MultipleUsersException, self).__init__(self.message) super(MultipleUsersException, self).__init__(self.message) # SystemUtils exceptions class IllegalCharacterException(Error): def __init__(self, name): self.message = "Illegal character found in: " + name super(IllegalCharacterException, self).__init__(self.message) # TapeClient exceptions # TapeClient exceptions class TapeClientException(Error): class TapeClientException(Error): Loading transfer_service/system_utils.py +19 −3 Original line number Original line Diff line number Diff line Loading @@ -6,9 +6,12 @@ # # import os import os import re import shutil import shutil import sys import sys from exceptions import IllegalCharacterException class SystemUtils(object): class SystemUtils(object): Loading Loading @@ -45,17 +48,30 @@ class SystemUtils(object): fp.close() fp.close() return False return False def findIllegalCharacters(self, name): """Checks for file/dir names containing illegal characters.""" pattern = re.compile(r"[<>?\":/|'*`\\]") if re.search(pattern, name): return True else: return False def scanRecursive(self, path): def scanRecursive(self, path): dirList = [] dirList = [] fileList = [] fileList = [] for folder, subfolders, files in os.walk(path, topdown = True): for folder, subfolders, files in os.walk(path, topdown = True): cwd = os.path.basename(folder) cwd = os.path.basename(folder) if folder != path: if folder != path: parent = os.path.dirname(folder) folderAbsPath = os.path.dirname(folder) + '/' + cwd dirList.append(parent + '/' + cwd) if self.findIllegalCharacters(cwd): raise(IllegalCharacterException(folderAbsPath)) dirList.append(folderAbsPath) i = 0 i = 0 for f in files: for f in files: files[i] = parent + '/' + cwd + '/' + f fileAbsPath = folderAbsPath + '/' + f if self.findIllegalCharacters(f): raise(IllegalCharacterException(fileAbsPath)) files[i] = fileAbsPath i += 1 i += 1 fileList.append(files) fileList.append(files) return [ dirList, fileList ] return [ dirList, fileList ] Loading Loading
transfer_service/exceptions.py +8 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,14 @@ class MultipleUsersException(Error): super(MultipleUsersException, self).__init__(self.message) super(MultipleUsersException, self).__init__(self.message) # SystemUtils exceptions class IllegalCharacterException(Error): def __init__(self, name): self.message = "Illegal character found in: " + name super(IllegalCharacterException, self).__init__(self.message) # TapeClient exceptions # TapeClient exceptions class TapeClientException(Error): class TapeClientException(Error): Loading
transfer_service/system_utils.py +19 −3 Original line number Original line Diff line number Diff line Loading @@ -6,9 +6,12 @@ # # import os import os import re import shutil import shutil import sys import sys from exceptions import IllegalCharacterException class SystemUtils(object): class SystemUtils(object): Loading Loading @@ -45,17 +48,30 @@ class SystemUtils(object): fp.close() fp.close() return False return False def findIllegalCharacters(self, name): """Checks for file/dir names containing illegal characters.""" pattern = re.compile(r"[<>?\":/|'*`\\]") if re.search(pattern, name): return True else: return False def scanRecursive(self, path): def scanRecursive(self, path): dirList = [] dirList = [] fileList = [] fileList = [] for folder, subfolders, files in os.walk(path, topdown = True): for folder, subfolders, files in os.walk(path, topdown = True): cwd = os.path.basename(folder) cwd = os.path.basename(folder) if folder != path: if folder != path: parent = os.path.dirname(folder) folderAbsPath = os.path.dirname(folder) + '/' + cwd dirList.append(parent + '/' + cwd) if self.findIllegalCharacters(cwd): raise(IllegalCharacterException(folderAbsPath)) dirList.append(folderAbsPath) i = 0 i = 0 for f in files: for f in files: files[i] = parent + '/' + cwd + '/' + f fileAbsPath = folderAbsPath + '/' + f if self.findIllegalCharacters(f): raise(IllegalCharacterException(fileAbsPath)) files[i] = fileAbsPath i += 1 i += 1 fileList.append(files) fileList.append(files) return [ dirList, fileList ] return [ dirList, fileList ] Loading