# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+from __future__ import division, print_function, unicode_literals
+
import os, sys, tempfile
import cumulus.store
self.path = url
self.prefix = self.path.rstrip("/")
- def _get_path(self, type, name):
- return os.path.join(self.prefix, type, name)
-
def list(self, subdir):
- return os.listdir(os.path.join(self.prefix, subdir))
+ try:
+ return os.listdir(os.path.join(self.prefix, subdir))
+ except OSError:
+ raise cumulus.store.NotFoundError(subdir)
def get(self, path):
- return open(os.path.join(self.prefix, path), 'rb')
+ try:
+ return open(os.path.join(self.prefix, path), 'rb')
+ except IOError:
+ raise cumulus.store.NotFoundError(path)
def put(self, path, fp):
- # TODO: Implement
- raise NotImplementedError
- k = self._get_path(type, name)
- out = open(k, 'wb')
+ out = open(os.path.join(self.prefix, path), 'wb')
buf = fp.read(4096)
while len(buf) > 0:
out.write(buf)
stat = os.stat(os.path.join(self.prefix, path))
return {'size': stat.st_size}
except OSError:
- raise cumulus.store.NotFoundError, path
+ raise cumulus.store.NotFoundError(path)
Store = FileStore