ftphelper.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:pydwd 作者: ckaus 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号