ssh: support opening files for writing

This commit is contained in:
Mr. Outis
2019-09-04 15:13:26 -05:00
parent 1ae9078fee
commit 9295bbd160
+5 -3
View File
@@ -251,12 +251,14 @@ class RemoteSSH(RemoteBASE):
@contextmanager
def open(self, path_info, mode="r", encoding=None):
with self.ssh(path_info) as ssh, closing(
ssh.sftp.file(path_info.path, mode="r")
ssh.sftp.open(path_info.path, mode)
) as fd:
if mode == "rb":
if "b" in mode:
yield fd
else:
yield io.TextIOWrapper(fd, encoding=encoding)
yield io.TextIOWrapper(
fd, encoding=encoding, write_through=True
)
def list_cache_paths(self):
with self.ssh(self.path_info) as ssh: