async def push(self, src_paths: List[str], container: FileContainer, dest_path: str) -> None: async with self.stub.push.open() as stream: await stream.send_message( PushRequest(inner=PushRequest.Inner( bundle_id=file_container_to_bundle_id_deprecated( container), dst_path=dest_path, container=file_container_to_grpc(container), ))) if self.is_local: for src_path in src_paths: await stream.send_message( PushRequest(payload=Payload(file_path=src_path))) await stream.end() await stream.recv_message() else: await drain_to_stream( stream=stream, generator=stream_map( generate_tar(paths=src_paths, verbose=self._is_verbose), lambda chunk: PushRequest(payload=Payload(data=chunk)), ), logger=self.logger, )
async def rm(self, container: FileContainer, paths: List[str]) -> None: await self.stub.rm( RmRequest( bundle_id=file_container_to_bundle_id_deprecated(container), paths=paths, container=file_container_to_grpc(container), ))
async def mkdir(self, container: FileContainer, path: str) -> None: await self.stub.mkdir( MkdirRequest( bundle_id=file_container_to_bundle_id_deprecated(container), path=path, container=file_container_to_grpc(container), ))
async def ls_single( self, container: FileContainer, path: str ) -> List[FileEntryInfo]: response = await self.stub.ls( LsRequest(path=path, container=file_container_to_grpc(container)) ) return [FileEntryInfo(path=file.path) for file in response.files]
async def mv(self, container: FileContainer, src_paths: List[str], dest_path: str) -> None: await self.stub.mv( MvRequest( src_paths=src_paths, dst_path=dest_path, container=file_container_to_grpc(container), ))
async def ls(self, container: FileContainer, path: str) -> List[FileEntryInfo]: response = await self.stub.ls( LsRequest( bundle_id=file_container_to_bundle_id_deprecated(container), path=path, container=file_container_to_grpc(container), )) return [FileEntryInfo(path=file.path) for file in response.files]
async def ls(self, container: FileContainer, paths: List[str]) -> List[FileListing]: response = await self.stub.ls( LsRequest(paths=paths, container=file_container_to_grpc(container)) ) return [ FileListing( parent=listing.parent.path, entries=[FileEntryInfo(path=entry.path) for entry in listing.files], ) for listing in response.listings ]
async def pull(self, container: FileContainer, src_path: str, dest_path: str) -> None: async with self.stub.pull.open() as stream: request = request = PullRequest( src_path=src_path, # not sending the destination to remote companion # so it streams the file back dst_path=dest_path if self.is_local else None, container=file_container_to_grpc(container), ) await stream.send_message(request) await stream.end() if self.is_local: await stream.recv_message() else: await drain_untar(generate_bytes(stream), output_path=dest_path) self.logger.info(f"pulled file to {dest_path}")
async def mkdir(self, container: FileContainer, path: str) -> None: await self.stub.mkdir( MkdirRequest(path=path, container=file_container_to_grpc(container)))
async def rm(self, container: FileContainer, paths: List[str]) -> None: await self.stub.rm( RmRequest(paths=paths, container=file_container_to_grpc(container)))