def get_modified_time_of_file(host, file_path, file_name):
modified_time = 0
try:
ftp = ftplib.FTP(host)
ftp.login()
ftp.cwd(file_path)
modified_time = ftp.sendcmd('MDTM %s' % file_name)[4:]
ftp.quit()
year = int(modified_time[:4])
month = int(modified_time[4:6])
day = int(modified_time[6:8])
hour = int(modified_time[8:10])
minute = int(modified_time[10:12])
seconds = int(modified_time[12:14])
remote_file_time = datetime.datetime(year, month, day, hour, minute, seconds)
modified_time = int(time.mktime(remote_file_time.timetuple()))
except ftplib.all_errors as e:
logger.warning('%s\nNot able to get date of remote description file. Check your connection' % e)
return modified_time
评论列表
文章目录