Crispin Wellington committed cdc664d

RemoteCache bugs

  • Participants
  • Parent commits 42c9cf7
  • Branches virtualenv-caching

Comments (0)

Files changed (1)

File parcel/

 import os
 import errno
-from fabric.contrib import file
+from fabric.contrib import files
+from fabric.api import run
 from import dl
 class RemoteCache(object):
-    def __init__(self, remote_path):
+    def __init__(self, remote_path, makedir=False):
+        if makedir:
+            if not files.exists(remote_path):
+                files.mkdir(remote_path)
         self.remote_path = remote_path
     def location(self, key):
-        return '{path}/{key}'.format(path=remote_path, key=key)
+        return '{path}/{key}'.format(path=self.remote_path, key=key)
     def is_cached(self, key):
-        return file.exists(self.location(key))
+        return files.exists(self.location(key))
     def delete(self, key):
         run('rm -rf "{location}"'.format(location=self.location(key)))
     def purge(self):
         """empty the cache of all stored folders"""
-        run('rm -rf "{remote_path}/*"'.format(remote_path=remote_path))
+        run('rm -rf "{remote_path}/*"'.format(remote_path=self.remote_path))
     def store(self, remote_path, key):
         """Store a full backup of `remote_path` under the `key`"""
     def get(self, key, remote_path):
-        """restore a folder aved under `key` to `remote_path`"""
+        """restore a folder saved under `key` to `remote_path`"""
         run('cp -Rl "{location}" "{remote_path}"'.format(remote_path=remote_path,
-                                                         location=selflocation(key)))
+                                                         location=self.location(key)))