Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes #29

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Next Next commit
Fix handling of scp command error.
  • Loading branch information
adiroiban committed May 19, 2014
commit c80ab7799438d783593561a2d2524150d72d1aae
17 changes: 15 additions & 2 deletions scp.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,21 @@ def get(self, remote_path, local_path='',
prsv = ('', ' -p')[preserve_times]
self.channel = self.transport.open_session()
self.channel.settimeout(self.socket_timeout)
self.channel.exec_command("scp%s%s -f %s" % (rcsv, prsv,
' '.join(remote_path)))

try:
self.channel.exec_command(
"scp%s%s -f %s" % (rcsv, prsv, ' '.join(remote_path)))
self._recv_all()
except:
# Check to see if we have some data on the channel.
data = self.channel.recv(self.buff_size)
if not data:
raise

code = data[0]
message = data[1:]
raise SCPException('%s %s' % (code, message))

self._recv_all()

if self.channel:
Expand Down