Commit 55e8570b authored by Jérome Perrin's avatar Jérome Perrin

SFTP: support old versions of paramiko

Conflicts:
	product/ERP5Type/ConnectionPlugin/SFTPConnection.py
parent eff1679f
......@@ -111,7 +111,15 @@ class SFTPConnection:
filepath = os.path.join(path, filename)
serialized_data = Binary(str(data))
try:
self.conn.putfo(StringIO(str(serialized_data)), filepath, confirm=confirm)
if hasattr(self.conn, 'putfo'):
# paramiko >= v1.10.0
self.conn.putfo(StringIO(str(serialized_data)), filepath, confirm=confirm)
else:
# older paramiko version
with tempfile.NamedTemporaryFile() as tmpfile:
tmpfile.write(str(serialized_data))
tmpfile.flush()
self.conn.put(tmpfile.name, filepath)
except error, msg:
raise SFTPError(str(msg) + ' while writing file %s on %s' % (filepath, path, self.url))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment