Example #1
0
 def system_remove(ToDelete):
     CreatesList = GetDependsCreates()[1]
     if IsntProtected(ToDelete) or any(
         [PathAlong(ToDelete, r) for r in CreatesList]):
         old_remove(ToDelete)
     else:
         raise BadCheckError(funcname(), None, ToDelete, [], CreatesList)
Example #2
0
 def system_rmtree(ToDelete, ignore_errors=False, onerror=None):
     CreatesList = GetDependsCreates()[1]
     if IsntProtected(ToDelete) or any(
         [PathAlong(ToDelete, r) for r in CreatesList]):
         old_rmtree(ToDelete, ignore_errors=ignore_errors, onerror=onerror)
     else:
         raise BadCheckError(funcname(), None, ToDelete, [], CreatesList)
Example #3
0
 def system_mkdir(DirName, mode=0777):
     CreatesList = GetDependsCreates()[1]
     if IsntProtected(DirName) or sum(
         [PathAlong(DirName, r) for r in CreatesList]) > 0:
         old_mkdir(DirName, mode)
     else:
         raise BadCheckError(funcname(), None, DirName, [], CreatesList)
 def system_copytree(tocopy,destination,symlinks=False):
     [DependencyList,CreatesList] = GetDependsCreates()
     Check = (IsntProtected(tocopy) or any([PathAlong(tocopy,r) for r in DependencyList+CreatesList])) and (IsntProtected(destination) or any([PathAlong(destination,r) for r in CreatesList]))
     if Check:
         old_copytree(tocopy,destination,symlinks=symlinks)  
     else: 
         raise BadCheckError(funcname(),tocopy,destination,DependencyList,CreatesList)
 def system_open(ToOpen,Mode='r',bufsize=1):
     [DependencyList,CreatesList] = GetDependsCreates()
     if IsntProtected(ToOpen) or any([PathAlong(ToOpen,r) for r in CreatesList]) if ('w' in Mode or 'a' in Mode) else any([PathAlong(ToOpen,r) for r in CreatesList + DependencyList]):  
         return old_open(ToOpen,Mode,bufsize)
     else:
         print(funcname(),caller(3),ToOpen if ('w' in Mode or 'a' in Mode) else None,DependencyList,CreatesList)
         raise BadCheckError(funcname(),ToOpen if 'r' in Mode else None,ToOpen if ('w' in Mode or 'a' in Mode) else None,DependencyList,CreatesList)
Example #6
0
 def system_getatime(ToAssay):
     [DependencyList, CreatesList] = GetDependsCreates()
     if IsntProtected(ToAssay) or any(
         [PathAlong(ToAssay, r) for r in DependencyList + CreatesList]):
         return old_atime(ToAssay)
     else:
         BadCheckError(funcname(), ToAssay, None,
                       DependencyList + CreatesList, None)
Example #7
0
 def system_isdir(ToCheck):
     [DependencyList, CreatesList] = GetDependsCreates()
     if IsntProtected(ToCheck) or any(
         [PathAlong(ToCheck, r) for r in DependencyList + CreatesList]):
         return old_isdir(ToCheck)
     else:
         BadCheckError(funcname(), ToCheck, None,
                       DependencyList + CreatesList, None)
Example #8
0
 def system_rename(old, new):
     CreatesList = GetDependsCreates()[1]
     if (IsntProtected(old)
             or any([PathAlong(old, r)
                     for r in CreatesList])) and (IsntProtected(new) or any(
                         [PathAlong(new, r) for r in CreatesList])):
         old_rename(old, new)
     else:
         raise BadCheckError(funcname(), None, [old, new], [], CreatesList)
Example #9
0
 def system_makedirs2(DirName, mode=0777):
     CreatesList = GetDependsCreates()[1]
     if IsntProtected(DirName) or any([
             PathAlong(DirName, r) or PathAlong(r, DirName)
             for r in CreatesList
     ]):
         old_makedirs2(DirName, mode)
     else:
         raise BadCheckError(funcname(), None, DirName, [], CreatesList)