Merge branch '1.10'

Conflicts:
	NEWS
This commit is contained in:
Jeff Forcier 2013-04-05 11:51:47 -07:00
commit 73a0d03bdc
3 changed files with 27 additions and 13 deletions

6
NEWS
View File

@ -25,6 +25,12 @@ v1.11.0 (DD MM YYYY)
implementations of all functionality. Thanks to Jason R. Coombs for the implementations of all functionality. Thanks to Jason R. Coombs for the
patch. patch.
v1.10.1 (DD MM YYYY)
--------------------
* #142: (Fabric #811) SFTP put of empty file will still return the attributes
of the put file. Thanks to Jason R. Coombs for the patch.
v1.10.0 (1st Mar 2013) v1.10.0 (1st Mar 2013)
-------------------- --------------------

View File

@ -575,7 +575,7 @@ class SFTPClient (BaseSFTP):
break break
finally: finally:
fr.close() fr.close()
if confirm and file_size: if confirm:
s = self.stat(remotepath) s = self.stat(remotepath)
if s.st_size != size: if s.st_size != size:
raise IOError('size mismatch in put! %d != %d' % (s.st_size, size)) raise IOError('size mismatch in put! %d != %d' % (s.st_size, size))

View File

@ -26,14 +26,12 @@ do test file operations in (so no existing files will be harmed).
from __future__ import with_statement from __future__ import with_statement
from binascii import hexlify from binascii import hexlify
import logging
import os import os
import random import warnings
import struct
import sys import sys
import threading import threading
import time
import unittest import unittest
import StringIO
import paramiko import paramiko
from stub_sftp import StubServer, StubSFTPServer from stub_sftp import StubServer, StubSFTPServer
@ -227,7 +225,7 @@ class SFTPTest (unittest.TestCase):
""" """
f = sftp.open(FOLDER + '/first.txt', 'w') f = sftp.open(FOLDER + '/first.txt', 'w')
try: try:
f.write('content!\n'); f.write('content!\n')
f.close() f.close()
sftp.rename(FOLDER + '/first.txt', FOLDER + '/second.txt') sftp.rename(FOLDER + '/first.txt', FOLDER + '/second.txt')
try: try:
@ -566,7 +564,6 @@ class SFTPTest (unittest.TestCase):
""" """
verify that get/put work. verify that get/put work.
""" """
import os, warnings
warnings.filterwarnings('ignore', 'tempnam.*') warnings.filterwarnings('ignore', 'tempnam.*')
localname = os.tempnam() localname = os.tempnam()
@ -631,7 +628,7 @@ class SFTPTest (unittest.TestCase):
try: try:
f = sftp.open(FOLDER + '/unusual.txt', 'wx') f = sftp.open(FOLDER + '/unusual.txt', 'wx')
self.fail('expected exception') self.fail('expected exception')
except IOError, x: except IOError:
pass pass
finally: finally:
sftp.unlink(FOLDER + '/unusual.txt') sftp.unlink(FOLDER + '/unusual.txt')
@ -671,12 +668,12 @@ class SFTPTest (unittest.TestCase):
f.close() f.close()
try: try:
f = sftp.open(FOLDER + '/zero', 'r') f = sftp.open(FOLDER + '/zero', 'r')
data = f.readv([(0, 12)]) f.readv([(0, 12)])
f.close() f.close()
f = sftp.open(FOLDER + '/zero', 'r') f = sftp.open(FOLDER + '/zero', 'r')
f.prefetch() f.prefetch()
data = f.read(100) f.read(100)
f.close() f.close()
finally: finally:
sftp.unlink(FOLDER + '/zero') sftp.unlink(FOLDER + '/zero')
@ -685,7 +682,6 @@ class SFTPTest (unittest.TestCase):
""" """
verify that get/put work without confirmation. verify that get/put work without confirmation.
""" """
import os, warnings
warnings.filterwarnings('ignore', 'tempnam.*') warnings.filterwarnings('ignore', 'tempnam.*')
localname = os.tempnam() localname = os.tempnam()
@ -730,3 +726,15 @@ class SFTPTest (unittest.TestCase):
finally: finally:
sftp.remove(FOLDER + '/append.txt') sftp.remove(FOLDER + '/append.txt')
def test_putfo_empty_file(self):
"""
Send an empty file and confirm it is sent.
"""
target = FOLDER + '/empty file.txt'
stream = StringIO.StringIO()
try:
attrs = sftp.putfo(stream, target)
# the returned attributes should not be null
self.assertNotEqual(attrs, None)
finally:
sftp.remove(target)