本文整理汇总了Python中ftplib.FTP_TLS.rename方法的典型用法代码示例。如果您正苦于以下问题:Python FTP_TLS.rename方法的具体用法?Python FTP_TLS.rename怎么用?Python FTP_TLS.rename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ftplib.FTP_TLS
的用法示例。
在下文中一共展示了FTP_TLS.rename方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import rename [as 别名]
# Download oldest & newest image
for image in images_to_upload:
print 'Downloading %s...' % image
ftps.retrbinary('RETR %s' % image, open(image, 'wb').write)
# Check if directory for old images exists, if not create it
if 'old' not in directory_list:
print 'Creating dir "old"...'
ftps.mkd('old')
# Move checked images to old
for image in image_list:
#date_str = image.split('_')[1].split('.')[0]
#img_date = datetime.strptime(date_str, '%Y%m%d-%H%M%S')
print 'Moving %s to "old"...' % image
ftps.rename(image, 'old/%s' % image)
# Disconnect from FTP server
ftps.quit()
def upload_image(filename):
image_file = {'file': open(filename, 'rb')}
print 'Uploading %s to GroupMe image service...' % filename
r = requests.post('%s?access_token=%s' % (GROUPME_IMAGE_URL, TOKEN), files=image_file)
# Get URL of image as given by GroupMe image service
return r.json()['payload']['url']
# Upload images to GroupMe image service
for image in images_to_upload:
image_url = upload_image(image)
# Delete image from local storage