mtth/hdfs — pull request #9 by borgstrom (2014-11-12 17:05:52+00:00)
Title: Allow an explicit temp directory to be supplied during download

I've run into a situation where the default tmp space on a server I'm using the HDFS client on is very small and I have no way to influence its size. The files I'm fetching from HDFS are large enough that I routinely see tracebacks like the following.

```
Traceback (most recent call last):
File "/usr/lib64/python2.6/multiprocessing/process.py", line 232, in _bootstrap
self.run()
File "/usr/lib64/python2.6/multiprocessing/process.py", line 88, in run
self._target(*self._args, **self._kwargs)
File "/export/content/lid/apps/bizoencrypter/bc8eae0055fe65af639468106d94f2a30c96c5e9/lib/python2.6/site-packages/bizoencrypter/worker.py", line 133, in wrap_target
target(*args, **kwargs)
File "/export/content/lid/apps/bizoencrypter/bc8eae0055fe65af639468106d94f2a30c96c5e9/lib/python2.6/site-packages/bizoencrypter/worker.py", line 410, in hdfs_worker
client.download(path, local_path, overwrite=True)
File "/export/content/lid/apps/bizoencrypter/bc8eae0055fe65af639468106d94f2a30c96c5e9/lib/python2.6/site-packages/hdfs/client.py", line 486, in download
_download((hdfs_path, local_path))
File "/export/content/lid/apps/bizoencrypter/bc8eae0055fe65af639468106d94f2a30c96c5e9/lib/python2.6/site-packages/hdfs/client.py", line 469, in _download
move(_temp_path, _local_path) # consistent with `mv` behavior
File "/usr/lib64/python2.6/contextlib.py", line 34, in __exit__
self.gen.throw(type, value, traceback)
File "/export/content/lid/apps/bizoencrypter/bc8eae0055fe65af639468106d94f2a30c96c5e9/lib/python2.6/site-packages/hdfs/util.py", line 160, in temppath
yield path
File "/export/content/lid/apps/bizoencrypter/bc8eae0055fe65af639468106d94f2a30c96c5e9/lib/python2.6/site-packages/hdfs/client.py", line 464, in _download
writer.write(chunk)
IOError: [Errno 28] No space left on device
```

This change allows one to specify an explicit directory to be used as temp space.