コード例 #1
0
 def copy(self, src_path_spec, dst_volume, dst_path_spec, remove=False):
     spath, sdir, sfile = src_path_spec
     dpath, ddir, dfile = dst_path_spec
     if not sfile:
         raise elFinder.Error("errNotFile")
     if not ddir:
         raise elFinder.Error("errNotFolder")
     if dfile:
         raise elFinder.Error("errCmdParams")
     dfile = dst_volume._copy_from(ddir, self, sdir, sfile)
     result = dict(added=[dst_volume.file_entry(ddir, dfile)])
     if remove:
         result["removed"] = [self.file_entry(sdir, sfile)["hash"]]
         self.remove(src_path_spec)
     return result
コード例 #2
0
 def add(self, path_spec, upload):
     import werkzeug  ### XXX
     path, gallery, file = path_spec
     MOM = self._scope.MOM
     if file:
         raise elFinder.Error("errTrgFolderNotFound")
     pics = sorted(gallery.pictures, key=lambda p: -p.number)
     if pics:
         number = pics[0].number + 1
     else:
         number = 0
     name, ext = os.path.splitext \
         (werkzeug.secure_filename (upload.filename))
     img  = self.PETM \
         ( gallery
         , number = number
         , name   = name
         , photo  = MOM._Pic_
             ( extension = ext
             )
         , thumb  = MOM._Thumb_
             ( extension = ext
             )
         )
     upload.save(img.photo.path)
     i = PIL.Image.open(img.photo.path)
     img.photo.width, img.photo.height = i.size
     i.thumbnail(self.thum_size, PIL.Image.ANTIALIAS)
     i.save(img.thumb.path)
     img.thumb.width, img.thumb.height = i.size
     return self.file_entry(gallery, img)
コード例 #3
0
 def decode_hashes(self, hashes):
     if len(hashes) > 2:
         raise elFinder.Error("errCmdParams")
     result = []
     dir = None
     file = None
     if hashes:
         dir_name = hashes.pop(0)
         dir = self.GETM.pid_query(dir_name)
         if not dir:
             raise elFinder.Error("errFolderNotFound", dir_name)
         result.append(dir.perma_name)
     if hashes:
         file_name = hashes.pop(0)
         file = self.PETM.pid_query(file_name)
         if not file:
             raise elFinder.Error("errFileNotFound", file_name)
         result.append(file.name)
     return "/".join(result), dir, file
コード例 #4
0
 def tree(self, path):
     path, dir, file = path
     result = []
     if not dir:
         raise elFinder.Error("errCmdParams")
     else:
         result.append(self.volume_entry())
         for b in self.dirs_of_path(path, dir):
             for d in self.directories(b):
                 result.append(self.directory_entry(d))
     return result
コード例 #5
0
 def remove(self, path_spec):  ### XXX
     path, gallery, picture = path_spec
     if picture:
         entry = self.file_entry(gallery, picture)
         picture.destroy()
     else:
         if not gallery.pictures:
             entry = self.directory_entry(gallery)
             gallery.destroy()
         else:
             raise elFinder.Error("errUsupportType")
     return entry
コード例 #6
0
 def add(self, path_spec, upload):
     import werkzeug  ### XXX
     path, dir, file = path_spec
     if file:
         raise elFinder.Error("errTrgFolderNotFound")
     abs_file_name = os.path.join \
         ( self.root_dir, dir.name
         , werkzeug.secure_filename (upload.filename)
         )
     rel_file_name = abs_file_name.replace(MOM.Web_Src_Root, "")
     upload.save(abs_file_name)
     i = PIL.Image.open(abs_file_name)
     w, h = i.size
     file = self.ETM(path=rel_file_name, width=w, height=h)
     self._scope.MOM.Id_Entity_has_Tag(file, ddir)
     return self.file_entry(dir, file)
コード例 #7
0
 def mkdir(self, dir, name):
     raise elFinder.Error("mkdir", name)
コード例 #8
0
ファイル: Connector.py プロジェクト: xiaochang91/tapyr
 def _handle_mkdir(self, request, response, method, volume, path_spec):
     path, dir, file = path_spec
     if file:
         raise elFinder.Error("errCmdParams")
     return dict \
         (added = [volume.mkdir (dir, request.req_data.get ("name"))])
コード例 #9
0
ファイル: Connector.py プロジェクト: xiaochang91/tapyr
 def _is_image(self, volume, file):
     self._is_file(volume, file)
     mime = volume.mime_type(file)
     if not mime.startswith("image"):
         raise elFinder.Error("errUsupportType")
コード例 #10
0
ファイル: Connector.py プロジェクト: xiaochang91/tapyr
 def _is_file(self, volume, file):
     if not file:
         raise elFinder.Error("errCmdParams")