def test_s3_timestamp(self): """ Verify that both kinds of s3 timestamps are handled properly """ ts1 = 'Wed, 12 Oct 2009 17:50:00 GMT' self.assertEqual(s3time_as_datetime(ts1), datetime.datetime(2009,10,12,17,50)) ts2 = '2015-07-08T14:50:48.000Z' self.assertEqual(s3time_as_datetime(ts2), datetime.datetime(2015,7,8,14,50,48)) return
def test_s3_timestamp(self): """ Verify that both kinds of s3 timestamps are handled properly """ ts1 = 'Wed, 12 Oct 2009 17:50:00 GMT' self.assertEqual(s3time_as_datetime(ts1), datetime.datetime(2009, 10, 12, 17, 50)) ts2 = '2015-07-08T14:50:48.000Z' self.assertEqual(s3time_as_datetime(ts2), datetime.datetime(2015, 7, 8, 14, 50, 48)) return
def should_upload(filepath, item, force_upload): """ Return true if the file at filepath should be uploaded, false otherwise. We upload if any of the following are true: - force_upload is True - the remote item doesn't exist - the checksums differ and the local file is newer """ if force_upload or not item: return True local_mtime = mtime_as_datetime(filepath) remote_mtime = s3time_as_datetime(item.last_modified) files_differ = not md5_matches(filepath, get_s3item_md5(item)) return files_differ and local_mtime >= remote_mtime
def should_download(item, filepath, force_download): """ Return true if item should be downloaded to filepath, false otherwise. We download if any of the following are true: - force_download is True - the file doesn't exist - the checksums differ and the remote file is newer """ if force_download or not os.path.exists(filepath): return True local_mtime = mtime_as_datetime(filepath) remote_mtime = s3time_as_datetime(item.last_modified) files_differ = not md5_matches(filepath, get_s3item_md5(item)) return files_differ and remote_mtime >= local_mtime