I want to do the equivalent of this shell script:
ssh visarend.solasistim.net tar -c /home/amoe/episodes | tar -vx -
But using Fabric 2.x. This is my attempt, but I'm not sure what the problem is.
remote_path = "/home/amoe/episodes"
c = fabric.Connection('visarend.solasistim.net')
with subprocess.Popen(['tar', '-vx'], stdin=subprocess.PIPE) as reader_proc:
c.run(
"tar -c %s" % (remote_path,),
out_stream=reader_proc.stdin
)
This gives me the error:
File "/usr/local/lib/python3.5/dist-packages/invoke/runners.py", line 525, in write_our_output
stream.write(encode_output(string, self.encoding))
TypeError: a bytes-like object is required, not 'str'
Along with some other errors. I understand that it's probably because the stream that I get from reader_proc.stdin
is a bytes stream, not a unicode stream. But I don't understand why run would need a unicode stream, or what the correct change would be to make it work.
from Fabric 2.x: tar and untar through pipe
No comments:
Post a Comment