diff options
| author | rr- <rr-@sakuya.pl> | 2016-05-20 21:34:02 +0200 |
|---|---|---|
| committer | rr- <rr-@sakuya.pl> | 2016-05-20 21:34:02 +0200 |
| commit | c88dfd228ac6feedd44fd82330b9899db863a190 (patch) | |
| tree | 8a6ee8ea995ed557dfdb3001d5731e2411d98853 /server/szurubooru/func/util.py | |
| parent | d2b9cece288cacd4c0f0306593d238d34639fd6d (diff) | |
server/images: replace pipes with temp files
ffmpeg's GIF demuxer needs the input stream to be seekable, which rules
pipes out.
Diffstat (limited to 'server/szurubooru/func/util.py')
| -rw-r--r-- | server/szurubooru/func/util.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/server/szurubooru/func/util.py b/server/szurubooru/func/util.py index f19e7fc..cdb9f81 100644 --- a/server/szurubooru/func/util.py +++ b/server/szurubooru/func/util.py @@ -1,8 +1,21 @@ +import os import datetime import hashlib import re +import tempfile +from contextlib import contextmanager from szurubooru.errors import ValidationError +@contextmanager +def create_temp_file(**kwargs): + (handle, path) = tempfile.mkstemp(**kwargs) + os.close(handle) + try: + with open(path, 'r+b') as handle: + yield handle + finally: + os.remove(path) + def unalias_dict(input_dict): output_dict = {} for key_list, value in input_dict.items(): |