plumbum
plumbum copied to clipboard
Redirection to remote path seems to write to local path
Redirecting a plumbum command to a remote path does not seem to write to the path on the remote machine. Is this a bug? To demonstrate what I mean:
from plumbum import local, SshMachine
user = '<redacted>'
host = '<redacted>'
ssh = SshMachine(host, user=user)
cmd = ssh['echo']
remote_path = ssh.path('/tmp/foo')
cmd_redirected = cmd['bar'] > remote_path
cmd_redirected()
local_contents = local['cat']('/tmp/foo')
print 'local contents:'
print local_contents
remote_contents = ssh['cat']('/tmp/foo')
print 'remote contents:'
print remote_contents
Running this (python 3.5.2 plumbum 1.6.6 from Pip) gives me this output:
local contents:
bar
Traceback (most recent call last):
File "demo.py", line 19, in <module>
remote_contents = ssh['cat']('/tmp/foo')
File "/usr/local/lib/python3.5/dist-packages/plumbum/commands/base.py", line 95, in __call__
return self.run(args, **kwargs)[1]
File "/usr/local/lib/python3.5/dist-packages/plumbum/commands/base.py", line 225, in run
return p.run()
File "/usr/local/lib/python3.5/dist-packages/plumbum/commands/base.py", line 187, in runner
return run_proc(p, retcode, timeout)
File "/usr/local/lib/python3.5/dist-packages/plumbum/commands/processes.py", line 206, in run_proc
return _check_process(proc, retcode, timeout, stdout, stderr)
File "/usr/local/lib/python3.5/dist-packages/plumbum/commands/processes.py", line 23, in _check_process
proc.verify(retcode, timeout, stdout, stderr)
File "/usr/local/lib/python3.5/dist-packages/plumbum/machines/base.py", line 22, in verify
stdout, stderr)
plumbum.commands.processes.ProcessExecutionError: Command line: ['/usr/bin/ssh', '<redacted>@<redacted>', 'cd', '/home/<redacted>', '&&', '/bin/cat', '/tmp/foo']
Exit code: 1
Stderr: | /bin/cat: /tmp/foo: No such file or directory