peppelorum

Untitled

May 16th, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. class CachedSFTPStorage(SFTPStorage):
  2.     """
  3.    SFTP storage backend that saves the files locally, too.
  4.    """
  5.     def __init__(self, *args, **kwargs):
  6.         super(CachedSFTPStorage, self).__init__(*args, **kwargs)
  7.         self.local_storage = get_storage_class(
  8.             "compressor.storage.CompressorFileStorage")()
  9.  
  10.     def save(self, name, content):
  11.         name = super(CachedSFTPStorage, self).save(name, content)
  12.         self.local_storage._save(name, content)
  13.         return name
  14.  
  15. #    def path(self, name):
  16. #        return None
  17. #        print self.local_storage.path(name)
  18. #        return self.local_storage.path(name)
  19.  
  20.     def _mkdir(self, path):
  21.         """Create directory, recursing up to create parent dirs if
  22.        necessary."""
  23.  
  24.         print 'path', path
  25.         parent = self._pathmod.dirname(path)
  26.         print 'parent', parent
  27. #        if not self.exists(parent):
  28. #            self._mkdir(parent)
  29.         self.sftp.mkdir(path) #This is the shit
  30.  
  31.         if self._dir_mode is not None:
  32.             self.sftp.chmod(path, self._dir_mode)
  33.  
  34.         if self._uid or self._gid:
  35.             self._chown(path, uid=self._uid, gid=self._gid)
Advertisement
Add Comment
Please, Sign In to add comment