Permalink
Browse files

Merge branch '1.10' into 1.11

  • Loading branch information...
2 parents 9dc7544 + 1bb422f commit e3a8fcddf6df07671bd6a031756281cf2ad165ee @bitprophet bitprophet committed Aug 22, 2016
Showing with 28 additions and 1 deletion.
  1. +5 −0 fabric/operations.py
  2. +1 −1 fabric/sftp.py
  3. +5 −0 sites/www/changelog.rst
  4. +17 −0 tests/test_operations.py
@@ -5,6 +5,7 @@
from __future__ import with_statement
+import errno
import os
import os.path
import posixpath
@@ -564,6 +565,10 @@ def get(remote_path, local_path=None, use_sudo=False, temp_dir=""):
or '*' in remote_path or '?' in remote_path
):
names = ftp.glob(remote_path)
+ # Handle "file not found" errors (like Paramiko does if we
+ # explicitly try to grab a glob-like filename).
+ if not names:
+ raise IOError(errno.ENOENT, "No such file")
else:
names = [remote_path]
View
@@ -62,7 +62,7 @@ def glob(self, path):
rlist = self.ftp.listdir(dirpart)
names = fnfilter([f for f in rlist if not f[0] == '.'], pattern)
- ret = [path]
+ ret = []
if len(names):
s = '/'
ret = [dirpart.rstrip(s) + s + name.lstrip(s) for name in names]
@@ -2,6 +2,11 @@
Changelog
=========
+* :bug:`1470` When using `~fabric.operations.get` with glob expressions, a lack
+ of matches for the glob would result in an empty file named after the glob
+ expression (in addition to raising an error). This has been fixed so the
+ empty file is no longer generated. Thanks to Georgy Kibardin for the catch &
+ initial patch.
* :support:`1483 backported` (also re: :issue:`1386`, :issue:`1374`,
:issue:`1300`) Add :ref:`an FAQ <faq-csh>` about quote problems in remote
``csh`` causing issues with Fabric's shell-wrapping and quote-escaping.
@@ -561,6 +561,23 @@ def test_directory_and_file_object_invalid(self):
self._invalid_file_obj_situations('/tree')
@server()
+ def test_nonexistent_glob_should_not_create_empty_files(self):
+ path = self.path()
+ with settings(hide('everything'), warn_only=True):
+ get('/nope*.txt', path)
+ assert not self.exists_locally(os.path.join(path, 'nope*.txt'))
+
+ @server()
+ def test_nonexistent_glob_raises_error(self):
+ try:
+ with hide('everything', 'aborts'):
+ get('/nope*.txt', self.path())
+ except SystemExit as e:
+ assert 'No such file' in e.message
+ else:
+ assert False
+
+ @server()
def test_get_single_file_absolutely(self):
"""
get() a single file, using absolute file path

0 comments on commit e3a8fcd

Please sign in to comment.