本文整理匯總了Python中app.models.Image.get_all_imgs方法的典型用法代碼示例。如果您正苦於以下問題:Python Image.get_all_imgs方法的具體用法?Python Image.get_all_imgs怎麽用?Python Image.get_all_imgs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app.models.Image
的用法示例。
在下文中一共展示了Image.get_all_imgs方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: remove_images
# 需要導入模塊: from app.models import Image [as 別名]
# 或者: from app.models.Image import get_all_imgs [as 別名]
def remove_images(app):
from datetime import datetime
while True:
time.sleep(1800)
conf = app.config['IMAGE_DELETE']
with app.app_context():
if ( datetime.utcnow().hour in conf['TIME_OF_DAY'] and
datetime.utcnow().weekday() in conf['WEEKDAY'] ):
images = Img.get_all_imgs()
db_imgs = [img.location + img.filename for img in images]
posts = Post.get_all()
post_imgs = get_all_imgs((post.body_html for post in posts))
diff_imgs = set(db_imgs) - set(post_imgs)
if diff_imgs:
app.logger.debug('Images to delete: {}'.format(db_imgs))
for i in images:
if i.location + i.filename in diff_imgs:
if os.path.isfile(imgs.path(i.filename)):
os.remove(imgs.path(i.filename))
f, e = os.path.splitext(i.filename)
if os.path.isfile(imgs.path(f + '_crop' + e)):
os.remove(imgs.path(f + '_crop' + e))
db.session.delete(i)
db.session.commit()