def stat(self): if self.content_provider.get(self.path) is None: return SFTP_NO_SUCH_FILE mtime = calendar.timegm(datetime.now().timetuple()) sftp_attrs = SFTPAttributes() sftp_attrs.st_size = self.content_provider.get_size(self.path) sftp_attrs.st_uid = 0 sftp_attrs.st_gid = 0 sftp_attrs.st_mode = (stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU | (stat.S_IFDIR if self.content_provider.is_dir( self.path) else stat.S_IFREG)) sftp_attrs.st_atime = mtime sftp_attrs.st_mtime = mtime sftp_attrs.filename = os.path.basename(self.path) return sftp_attrs
def utime(self, times): """ Set the access and modified times of this file. If C{times} is C{None}, then the file's access and modified times are set to the current time. Otherwise, C{times} must be a 2-tuple of numbers, of the form C{(atime, mtime)}, which is used to set the access and modified times, respectively. This bizarre API is mimicked from python for the sake of consistency -- I apologize. @param times: C{None} or a tuple of (access time, modified time) in standard internet epoch time (seconds since 01 January 1970 GMT) @type times: tuple(int) """ if times is None: times = (time.time(), time.time()) self.sftp._log(DEBUG, 'utime(%s, %r)' % (hexlify(self.handle), times)) attr = SFTPAttributes() attr.st_atime, attr.st_mtime = times self.sftp._request(CMD_FSETSTAT, self.handle, attr)
def utime(self, times): """ Set the access and modified times of this file. If ``times`` is ``None``, then the file's access and modified times are set to the current time. Otherwise, ``times`` must be a 2-tuple of numbers, of the form ``(atime, mtime)``, which is used to set the access and modified times, respectively. This bizarre API is mimicked from Python for the sake of consistency -- I apologize. :param tuple times: ``None`` or a tuple of (access time, modified time) in standard internet epoch time (seconds since 01 January 1970 GMT) """ if times is None: times = (time.time(), time.time()) self.sftp._log(DEBUG, 'utime({}, {!r})'.format(hexlify(self.handle), times)) attr = SFTPAttributes() attr.st_atime, attr.st_mtime = times self.sftp._request(CMD_FSETSTAT, self.handle, attr)
def utime(self, path, times): """ Set the access and modified times of the file specified by ``path``. If ``times`` is ``None``, then the file's access and modified times are set to the current time. Otherwise, ``times`` must be a 2-tuple of numbers, of the form ``(atime, mtime)``, which is used to set the access and modified times, respectively. This bizarre API is mimicked from Python for the sake of consistency -- I apologize. :param str path: path of the file to modify :param tuple times: ``None`` or a tuple of (access time, modified time) in standard internet epoch time (seconds since 01 January 1970 GMT) """ path = self._adjust_cwd(path) if times is None: times = (time.time(), time.time()) self._log(DEBUG, 'utime(%r, %r)' % (path, times)) attr = SFTPAttributes() attr.st_atime, attr.st_mtime = times self._request(CMD_SETSTAT, path, attr)
def utime(self, times): """ Set the access and modified times of this file. If ``times`` is ``None``, then the file's access and modified times are set to the current time. Otherwise, ``times`` must be a 2-tuple of numbers, of the form ``(atime, mtime)``, which is used to set the access and modified times, respectively. This bizarre API is mimicked from Python for the sake of consistency -- I apologize. :param tuple times: ``None`` or a tuple of (access time, modified time) in standard internet epoch time (seconds since 01 January 1970 GMT) """ if times is None: times = (time.time(), time.time()) self.sftp._log( DEBUG, "utime({}, {!r})".format(hexlify(self.handle), times) ) attr = SFTPAttributes() attr.st_atime, attr.st_mtime = times self.sftp._request(CMD_FSETSTAT, self.handle, attr)
def utime(self, path, times): """ Set the access and modified times of the file specified by C{path}. If C{times} is C{None}, then the file's access and modified times are set to the current time. Otherwise, C{times} must be a 2-tuple of numbers, of the form C{(atime, mtime)}, which is used to set the access and modified times, respectively. This bizarre API is mimicked from python for the sake of consistency -- I apologize. @param path: path of the file to modify. @type path: string @param times: C{None} or a tuple of (access time, modified time) in standard internet epoch time (seconds since 01 January 1970 GMT). @type times: tuple of int """ path = self._adjust_cwd(path) if times is None: times = (time.time(), time.time()) attr = SFTPAttributes() attr.st_atime, attr.st_mtime = times self._request(CMD_SETSTAT, path, attr)
def stat(self): if self.content_provider.get(self.path) is None: return SFTP_NO_SUCH_FILE mtime = calendar.timegm(datetime.now().timetuple()) sftp_attrs = SFTPAttributes() sftp_attrs.st_size = self.content_provider.get_size(self.path) sftp_attrs.st_uid = 0 sftp_attrs.st_gid = 0 sftp_attrs.st_mode = ( stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU | ( stat.S_IFDIR if self.content_provider.is_dir(self.path) else stat.S_IFREG ) ) sftp_attrs.st_atime = mtime sftp_attrs.st_mtime = mtime sftp_attrs.filename = os.path.basename(self.path) return sftp_attrs