Пример #1
0
    def stat(self, name):
        ap = self.abspath(name)
        if ap in ("/", "/.", "./", "//", ""):
            bytes = 0
            isdir = True
        else:
            try:
                meta = self.client.files_get_metadata(ap)
            except dropbox.exceptions.ApiError as e:
                raise OperationFailure(e.message)
            if isinstance(
                    meta,
                (dropbox.files.FolderMetadata,
                 dropbox.sharing.SharedFolderMetadata),
            ):
                bytes = 0
                isdir = True
            else:
                bytes = meta.size
                isdir = False

        type_ = stat.S_IFDIR if isdir else stat.S_IFREG
        m = calc_mode(type=type_)
        s = make_stat(size=bytes, mode=m)
        return s
Пример #2
0
	def stat(self, name):
		ap = self.abspath(name)
		self.log("stat: {p}\n".format(p=ap))
		op = self.path
		try:
			size, type = self._get_total_size_and_type(ap)
		except Exception as e:
			self.log("Error during stat: {e}\n".format(e=e.message))
			raise OperationFailure(e.message)
		finally:
			self.ftp.cwd(op)
		# todo: check permissions
		m = calc_mode(type=type)
		return make_stat(size=size, mode=m)
Пример #3
0
 def stat(self, name):
     ap = self.abspath(name)
     self.log("stat: {p}\n".format(p=ap))
     op = self.path
     try:
         size, type = self._get_total_size_and_type(ap)
     except Exception as e:
         self.log("Error during stat: {e}\n".format(e=e.message))
         raise OperationFailure(e.message)
     finally:
         self.ftp.cwd(op)
     # todo: check permissions
     m = calc_mode(type=type)
     return make_stat(size=size, mode=m)
Пример #4
0
 def stat(self, name):
     ap = self.abspath(name)
     self.log("stat: {ap}\n".format(ap=ap))
     isdir = self.isdir(name)
     isfile = self.isfile(name)
     if not (isdir or isfile):
         self.log("stat-target not found.\n")
         raise errors.OperationFailure("Not found!")
     if isdir:
         size = 1
         mtime = None
     else:
         zipinfo = self.zf.getinfo(ap)
         size = zipinfo.file_size
         timestamp = zipinfo.date_time
         dt = datetime.datetime(*timestamp)
         mtime = (dt - datetime.datetime(1970, 1, 1)).total_seconds()
     type_ = (stat.S_IFREG if isfile else stat.S_IFDIR)
     mode = base.calc_mode(type=type_)
     self.log("stat return\n")
     return base.make_stat(size=size, mtime=mtime, ctime=mtime, mode=mode)
Пример #5
0
	def stat(self, name):
		ap = self.abspath(name)
		self.log("stat: {ap}\n".format(ap=ap))
		isdir = self.isdir(name)
		isfile = self.isfile(name)
		if not (isdir or isfile):
			self.log("stat-target not found.\n")
			raise errors.OperationFailure("Not found!")
		if isdir:
			size = 1
			mtime = None
		else:
			zipinfo = self.zf.getinfo(ap)
			size = zipinfo.file_size
			timestamp = zipinfo.date_time
			dt = datetime.datetime(*timestamp)
			mtime = (dt - datetime.datetime(1970, 1, 1)).total_seconds()
		type_ = (stat.S_IFREG if isfile else stat.S_IFDIR)
		mode = base.calc_mode(type=type_)
		self.log("stat return\n")
		return base.make_stat(
			size=size, mtime=mtime, ctime=mtime, mode=mode
			)
Пример #6
0
	def stat(self, name):
		ap = self.abspath(name)
		if ap in ("/", "/.", "./", "//", ""):
			bytes = 0
			isdir = True
		else:
			try:
				meta = self.client.files_get_metadata(ap)
			except dropbox.exceptions.ApiError as e:
				raise OperationFailure(e.message)
			if isinstance(meta, (
				dropbox.files.FolderMetadata,
				dropbox.sharing.SharedFolderMetadata
				)):
				bytes = 0
				isdir = True
			else:
				bytes = meta.size
				isdir = False
			
		type_ = (stat.S_IFDIR if isdir else stat.S_IFREG)
		m = calc_mode(type=type_)
		s = make_stat(size=bytes, mode=m)
		return s