summaryrefslogtreecommitdiff
path: root/paramiko/sftp.py
diff options
context:
space:
mode:
authorScott Maxwell <scott@codecobblers.com>2013-10-30 17:09:34 -0700
committerScott Maxwell <scott@codecobblers.com>2013-10-30 17:09:34 -0700
commit0e4ce3762a5b25c5d3eb89335495d3bb9054e3e7 (patch)
treea77bfec4e3a29e9827d4e75de932e34947536181 /paramiko/sftp.py
parent339d73cc13765bea4dd5b683ca14b02c9baa589f (diff)
downloadparamiko-0e4ce3762a5b25c5d3eb89335495d3bb9054e3e7.tar.gz
Fix message sending
Create constants for byte messages, implement asbytes so many methods can take Message and key objects directly and split get_string into get_text and get_binary. Also, change int handling to use mpint with a flag whenever the int is greater than 32 bits.
Diffstat (limited to 'paramiko/sftp.py')
-rw-r--r--paramiko/sftp.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/paramiko/sftp.py b/paramiko/sftp.py
index a97c300f..0d1287a5 100644
--- a/paramiko/sftp.py
+++ b/paramiko/sftp.py
@@ -86,7 +86,7 @@ CMD_NAMES = {
CMD_ATTRS: 'attrs',
CMD_EXTENDED: 'extended',
CMD_EXTENDED_REPLY: 'extended_reply'
- }
+}
class SFTPError (Exception):
@@ -125,7 +125,7 @@ class BaseSFTP (object):
msg = Message()
msg.add_int(_VERSION)
msg.add(*extension_pairs)
- self._send_packet(CMD_VERSION, str(msg))
+ self._send_packet(CMD_VERSION, msg)
return version
def _log(self, level, msg, *args):
@@ -167,6 +167,7 @@ class BaseSFTP (object):
def _send_packet(self, t, packet):
#self._log(DEBUG2, 'write: %s (len=%d)' % (CMD_NAMES.get(t, '0x%02x' % t), len(packet)))
out = struct.pack('>I', len(packet) + 1) + chr(t) + packet
+ packet = asbytes(packet)
if self.ultra_debug:
self._log(DEBUG, util.format_binary(out, 'OUT: '))
self._write_all(out)