def get_mtime(self, name):
""" Return modification time of the file in ftp server.
If the file does not exist, return None.
If the name refers to a directory, return 0.
To get the local modification time, use
``get_mtime()-clock_offset``.
"""
filename = self.abspath(name)
try:
resp = self.ftp.sendcmd('MDTM ' + filename.replace('\\', '/'))
except error_perm, msg:
s = str(msg)
if s.startswith('550 I can only retrieve regular files'):
# filename is directory
return 0
if s.startswith('550 Can\'t check for file existence'):
# file with filename does not exist
return None
raise
assert resp[:3]=='213', `resp, filename`
modtime = int(time.mktime(time.strptime(resp[3:].strip(), '%Y%m%d%H%M%S')))
return modtime
评论列表
文章目录