diff options
author | Muthu Subramanian <sumuthu@suse.com> | 2013-04-10 10:59:42 +0200 |
---|---|---|
committer | Thorsten Behrens <tbehrens@suse.com> | 2013-04-10 11:00:55 +0200 |
commit | c1ef003f69ae563bcc8d543a6c397f08cb930628 (patch) | |
tree | e0f29ce9a2c50310b6b6b49d6333f4a0e3ee9021 | |
parent | fb1aabf24ebbc684a60ceafb7c41d537be5c796a (diff) |
Move out thumbnailer to separate script, to-be-run via cron.
-rwxr-xr-x | slideapi.py | 9 | ||||
-rwxr-xr-x | updatedeck.py | 22 |
2 files changed, 23 insertions, 8 deletions
diff --git a/slideapi.py b/slideapi.py index 3335fd1..ecfdeff 100755 --- a/slideapi.py +++ b/slideapi.py @@ -141,14 +141,7 @@ def upload_deck(user,deck): 'upload_filename': content.filename}, out) - thumbnail_size = '128x128' - - # override defaults by config - if "thumbnails" in local_conf: - thumbnails_dict = local_conf["thumbnails"] - thumbnail_size = thumbnails_dict['thumbnail_size'] if 'thumbnail_size' in thumbnails_dict else thumbnail_size - - os.system('./convert_deck.sh '+upload_path+' '+thumbnail_size) + # thumbnail generation happens asynchronously via updatedeck.py return 'Success:'+tag+':'+content.filename diff --git a/updatedeck.py b/updatedeck.py new file mode 100755 index 0000000..48f9e2d --- /dev/null +++ b/updatedeck.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +import fnmatch +import os +from subprocess import call + +# Logic: +# Find all *.*odp recursively and see if there are corresponding .pngs +# if not call convert_deck.sh + +matches = [] +for root, dirnames, filenames in os.walk('filestore'): + for filename in fnmatch.filter(filenames, 'deck*.*odp'): + if len(fnmatch.filter(filenames, 'deck*.png')) <= 0: + call(['./convert_deck.sh', root, '128x128']) |