From 74fba053021eb4e71d3dad4303f938e0684d4646 Mon Sep 17 00:00:00 2001 From: rr- Date: Thu, 2 Jun 2016 01:15:54 +0200 Subject: [PATCH] server/tools: add generate-thumb --- server/generate-thumb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 server/generate-thumb diff --git a/server/generate-thumb b/server/generate-thumb new file mode 100755 index 00000000..87d7e02b --- /dev/null +++ b/server/generate-thumb @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +''' +Generates thumbnails for posts from CLI. Useful for testing changes to +thumbnail generators, and for weird inputs. +''' + +import argparse +import os.path +import sys +from szurubooru.func import posts + +def main(): + parser = argparse.ArgumentParser('Starts szurubooru using waitress.') + parser.add_argument('post_id', metavar='POST', help='post to generate thumbnail for') + args = parser.parse_args() + + try: + post = posts.get_post_by_id(args.post_id) + posts.generate_post_thumbnail(post) + except posts.PostNotFoundError: + pass + except: + raise + +if __name__ == '__main__': + main()