From d9f1d8d40e9afad78c7cc54bd189556ad9b91d62 Mon Sep 17 00:00:00 2001 From: yomguy Date: Wed, 30 Mar 2011 01:21:44 +0200 Subject: [PATCH] speed up forst process by adding the default waveform to the pipe --- telemeta/web/base.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/telemeta/web/base.py b/telemeta/web/base.py index 6d9a7f62..8275aa8e 100644 --- a/telemeta/web/base.py +++ b/telemeta/web/base.py @@ -389,6 +389,13 @@ class WebView(object): item.approx_duration = str(time) item.save() else: + # process first waveform to speed up imports + width = 360 + height = 130 + size = str(width) + '_' + str(height) + grapher_id = 'waveform' + image_file = '.'.join([public_id, grapher_id, size, 'png']) + analyzers = [] analyzers_sub = [] if item.file: @@ -398,7 +405,18 @@ class WebView(object): subpipe = analyzer() analyzers_sub.append(subpipe) pipe = pipe | subpipe + if not self.cache_data.exists(image_file): + path = self.cache_data.dir + os.sep + image_file + for grapher in self.graphers: + if grapher.id() == grapher_id: + break + graph = grapher(width = int(width), height = int(height)) + pipe = pipe | graph pipe.run() + if not self.cache_data.exists(image_file): + f = open(path, 'w') + graph.render(path) + f.close() mime_type = decoder.format() analyzers.append({'name': 'Mime type', 'id': 'mime_type', 'unit': '', 'value': mime_type}) analyzers.append({'name': 'Channels', 'id': 'channels', 'unit': '', 'value': decoder.channels()}) -- 2.39.5