Ejemplo n.º 1
0
 def obtain(self, path, limit=None):
     path_for_dropbox = ensure_binary_string(path)
     logging.debug(u"Obtaining file: %s", path)
     metadata = self.list(path)
     if limit and metadata['bytes'] > limit:
         raise OverLimit("The response contains %d bytes data."\
                         % metadata['bytes'])
     res = self.client.get_file(path_for_dropbox)
     file_obj = StringIO(res.read())
     file_obj.name = path
     return file_obj
Ejemplo n.º 2
0
    def list(self, path, recursive=True):
        if path in self.cached_list:
            return self.cached_list[path]
        if recursive:
            result = self.list(path, recursive=False)
            if result['is_dir']:
                def _ls_rec(data):
                    if data['is_dir']:
                        data.update(self.list(data['path'], recursive=False))

                traverse(_ls_rec, result)
            return result
        else:
            path_for_dropbox = ensure_binary_string(path)
            logging.debug(u"Listing metadata of: %s", path)
            result = self.client.metadata(path_for_dropbox)
            self.cached_list[path] = result
            return result
Ejemplo n.º 3
0
 def move(self, from_path, to_path):
     from_path_for_dropbox = ensure_binary_string(from_path)
     to_path_for_dropbox = ensure_binary_string(to_path)
     logging.debug(u"Moving into: %s %s", from_path, to_path)
     return self.client.file_move(from_path_for_dropbox,
                                  to_path_for_dropbox)
Ejemplo n.º 4
0
 def create_folder(self, path):
     path_for_dropbox = ensure_binary_string(path)
     logging.debug(u"Creating a directory: %s", path)
     return self.client.file_create_folder(path_for_dropbox)
Ejemplo n.º 5
0
 def delete(self, path):
     path_for_dropbox = ensure_binary_string(path)
     logging.debug(u"Deleting file from Dropbox: %s", path)
     return self.client.file_delete(path_for_dropbox)
Ejemplo n.º 6
0
 def put(self, path, file_obj, overwrite=True):
     path_for_dropbox = ensure_binary_string(path)
     logging.debug(u"Putting file to Dropbox: %s", path)
     return self.client.put_file(path_for_dropbox,
                                 file_obj, overwrite=overwrite)