def _make_dir(self, folder): """ Create a folder on thel FTP service. If its relative, the folder is made relative to cwd. Otherwise its absolute. We do it by attempting to create every folder in the chain. """ folder = utils.join_paths(self.root, folder) self._pushd(".") try: # Get all the anscestor paths. paths = utils.ancestor_paths(folder) for path in paths: if not path in ["", ".", "..", "/"]: try: # If we can't chdir, then we try to build self._pushd(path) self._popd() except: # If we fail to build - we fail if self.sftp and use_paramiko: self.ftp.mkdir(path) else: self.ftp.mkd(path) finally: self._popd()
def check_exclusion(self, path): _, ext = os.path.splitext(path) ext = ext[1:].lower() # Remove the '.' # Is this file excluded by type if ext in self.excl_ext: return True # Is this file excluded by filename/folder/glob ancestors = utils.ancestor_paths(path) #log.debug("Ancestor Pathlist:", ",".join(ancestors)) for patt in self.backup.exclude_patterns: for path in ancestors: if fnmatch.fnmatch(path, patt): return True return False