pushyrpc / pushy

Easy-as RPC. Zero-server RPC for Python and Java.
http://github.com/pushyrpc/pushy
45 stars 18 forks source link

putfile doesn't redirect stdout #41

Closed bradharmon closed 11 years ago

bradharmon commented 11 years ago

whenever I use pushy's putfile method, I get output to stdout. Even redirecting stdout doesn't work:

conn = pushy.connect("ssh:hostname")

saved_stdout = sys.stdout
devnull = open(os.devnull, 'w')
sys.stdout = devnull

conn.putfile(src, dst)

sys.stdout = saved_stdout
devnull.close()
axw commented 11 years ago

Apologies for not responding sooner, I've been without regular Internet access.

What is the output you're getting? What OS are you running this on? If it's Windows, do you have Paramiko installed, or are you relying on PuTTY?

bradharmon commented 11 years ago

I'm running on linux. It looks like what is happening is that the standard scp library is being used, however, when Popen is called, stdout and stderr don't get overridden with anything, so I see the standard scp output that shows a progress bar. And it overwrites anything that was already printed on that line. I finally figured out how to suppress the output, but it seems like output to stdout/stderr should automatically be suppressed within the library.

Here is the relevant code I am referring to in pushy pushy/transport/ssh.py:269

if is_windows or self.__password is None:
   proc = subprocess.Popen(args, stdin=subprocess.PIPE)
else:
   proc = pushy.util.askpass.Popen(args, self.__password,
                                                    stdin=subprocess.PIPE)
proc.stdin.close()
return proc.wait()
axw commented 11 years ago

I see, thanks for that. I'm not sure about suppressing output altogether, in case important errors (or security warnings) get suppressed. Adding "-q" to the scp/pscp args will work for the success case.