Also added some tests for the use_sudo + temp_dir combination for operations.put()
Added `use_sudo` and `temp_dir` params to `operations.get()`. Fixes #700
Linking to #700 since the mention in the subject didn't do so :) (and - thanks! Labeling for followup.)
Merging and testing this now and there's a problem, at least on my localhost system (OS X / BSD userland) the chmod this code adds causes the file to be unreadable, resulting in an IOError from Paramiko's SFTP module, and a created-but-empty local file at the expected path.
The reason it fails is because the chmod is 0404 intending it to be root and owner readable...but the file is already owned by root at this point in time (and then when it's copied by SFTP)! I.e. sudo cp creates a new file owned by root, not by the original owner.
Both BSD and Linux versions of cp seem to support the -p flag which preserves user/group/timestamps - this feels more like what we want anyways. I am adding this for now.
Add missing (or removed in interim?) import for tests re #1121
Does not work yet for directories :)
example: get('/data/media/', use_sudo=True)
The problem comes from sftp.glob
The glob function does not suppert use_sudo param. Called from fabric.operations.get