def listdir_stats(self, path, params=None, **kwargs): """ List the stats for the directories inside the specified path Returns the Multiple ABFFStat object #note change later for recursive cases """ if ABFS.isroot(path): return self.listfilesystems_stats(params=None, **kwargs) dir_stats = [] file_system, directory_name, account = Init_ABFS.parse_uri(path) root = Init_ABFS.ABFS_ROOT if path.lower().startswith(Init_ABFS.ABFS_ROOT_S): root = Init_ABFS.ABFS_ROOT_S if params is None: params = {} if 'recursive' not in params: params['recursive'] = 'false' params['resource'] = 'filesystem' if directory_name != "": params['directory'] = directory_name res = self._root._invoke("GET", file_system, params, headers=self._getheaders(), **kwargs) resp = self._root._format_response(res) if account != '': file_system = file_system + account for x in resp['paths']: dir_stats.append( ABFSStat.for_directory(res.headers, x, root + file_system + "/" + x['name'])) return dir_stats
def listdir_stats(self, path, params=None, **kwargs): """ List the stats for the directories inside the specified path Returns the Multiple ABFFStat object #note change later for recursive cases """ if ABFS.isroot(path): LOG.warn("Path: %s is a Filesystem" % path) return self.listfilesystems_stats(params=None, **kwargs) dir_stats = [] file_system, directory_name = Init_ABFS.parse_uri(path)[:2] if params is None: params = {} if 'recursive' not in params: params['recursive'] = 'false' params['resource'] = 'filesystem' if directory_name != "": params['directory'] = directory_name res = self._root._invoke("GET", file_system, params, headers=self._getheaders(), **kwargs) resp = self._root._format_response(res) for x in resp['paths']: dir_stats.append( ABFSStat.for_directory( res.headers, x, Init_ABFS.ABFS_ROOT + file_system + "/" + x['name'])) return dir_stats
def stats(self, path, params=None, **kwargs): """ List the stat of the actual file/directory Returns the ABFFStat object """ if ABFS.isroot(path): return ABFSStat.for_root(path) file_system, dir_name = Init_ABFS.parse_uri(path)[:2] if dir_name == '': LOG.debug("Path being called is a Filesystem") return ABFSStat.for_filesystem(self._statsf(file_system, params, **kwargs), path) return ABFSStat.for_single(self._stats(file_system + '/' +dir_name, params, **kwargs), path)
def _create_path(self, path, params=None, headers=None, overwrite=False): """ Container method for Create """ file_system, dir_name = Init_ABFS.parse_uri(path)[:2] if dir_name == '': return self._create_fs(file_system) no_scheme = file_system + '/' + dir_name additional_header = self._getheaders() if headers is not None: additional_header.update(headers) if not overwrite: additional_header['If-None-Match'] = '*' self._root.put(no_scheme, params, headers=additional_header)
def stats(self, path, params=None, **kwargs): """ List the stat of the actual file/directory Returns the ABFFStat object """ if ABFS.isroot(path): return ABFSStat.for_root(path) try: file_system, dir_name = Init_ABFS.parse_uri(path)[:2] except: raise IOError if dir_name == '': return ABFSStat.for_filesystem( self._statsf(file_system, params, **kwargs), path) return ABFSStat.for_single( self._stats(file_system + '/' + dir_name, params, **kwargs), path)
def _delete(self, path, recursive='false', skip_trash=True): """ Wrapper function for calling delete, no support for trash or """ if not skip_trash: raise NotImplementedError("Trash not implemented for ABFS") if ABFS.isroot(path): raise RuntimeError("Cannot Remove Root") file_system, dir_name = Init_ABFS.parse_uri(path)[:2] if dir_name == '': return self._root.delete(file_system, {'resource': 'filesystem'}, headers=self._getheaders()) new_path = file_system + '/' + dir_name param = None if self.isdir(path): param = {'recursive' : recursive} self._root.delete(new_path, param, headers=self._getheaders())
def __init__(self, request): super(ABFSFileUploadHandler, self).__init__(request) self.chunk_size = DEFAULT_WRITE_SIZE self.destination = request.GET.get('dest', None) # GET param avoids infinite looping self.target_path = None self.file = None self._request = request self._part_size = DEFAULT_WRITE_SIZE if self._is_abfs_upload(): self._fs = self._get_abfs(request) self.filesystem, self.directory = parse_uri(self.destination)[:2] # Verify that the path exists self._fs.stats(self.destination) LOG.debug("Chunk size = %d" % DEFAULT_WRITE_SIZE)