# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2010 Samalyse SARL
+# Copyright (C) 2010 Samalyse SARL
# Copyright (C) 2010-2014 Parisson SARL
# This software is a computer program whose purpose is to backup, analyse,
from django.forms.models import model_to_dict
+strict_code = getattr(settings, 'TELEMETA_STRICT_CODE', False)
+
# Special code regex of collections for the branch
collection_published_code_regex = getattr(settings, 'COLLECTION_PUBLISHED_CODE_REGEX', '[A-Za-z0-9._-]*')
collection_unpublished_code_regex = getattr(settings, 'COLLECTION_UNPUBLISHED_CODE_REGEX', '[A-Za-z0-9._-]*')
return False
def clean(self):
- if self.code and not self.is_valid_code(self.code):
- raise ValidationError("%s is not a valid item code for collection %s"
- % (self.code, self.collection.code))
+ if strict_code:
+ if self.code and not self.is_valid_code(self.code):
+ raise ValidationError("%s is not a valid item code for collection %s"
+ % (self.code, self.collection.code))
def save(self, force_insert=False, force_update=False):
super(MediaItem, self).save(force_insert, force_update)
from telemeta.views.core import *
+import timeside.core
class ItemBaseMixin(object):
- graphers = timeside.core.processors(timeside.api.IGrapher)
- decoders = timeside.core.processors(timeside.api.IDecoder)
- encoders = timeside.core.processors(timeside.api.IEncoder)
- analyzers = timeside.core.processors(timeside.api.IAnalyzer)
- value_analyzers = timeside.core.processors(timeside.api.IValueAnalyzer)
+ graphers = timeside.core.processor.processors(timeside.core.api.IGrapher)
+ decoders = timeside.core.processor.processors(timeside.core.api.IDecoder)
+ encoders = timeside.core.processor.processors(timeside.core.api.IEncoder)
+ analyzers = timeside.core.processor.processors(timeside.core.api.IAnalyzer)
+ value_analyzers = timeside.core.processor.processors(timeside.core.api.IValueAnalyzer)
cache_data = TelemetaCache(settings.TELEMETA_DATA_CACHE_DIR)
cache_export = TelemetaCache(settings.TELEMETA_EXPORT_CACHE_DIR)
source = item.get_source()
if source:
- decoder = timeside.decoder.file.FileDecoder(source)
+ decoder = timeside.core.get_processor('file_decoder')(source)
pipe = decoder
for analyzer in self.value_analyzers:
source = item.get_source()
if source:
path = self.cache_data.dir + os.sep + image_file
- decoder = timeside.decoder.file.FileDecoder(source)
+ decoder = timeside.core.get_processor('file_decoder')(source)
graph = grapher(width=width, height=height)
(decoder | graph).run()
graph.watermark('timeside', opacity=.6, margin=(5,5))
media = self.cache_export.dir + os.sep + file
if not self.cache_export.exists(file) or not flag.value:
# source > encoder > stream
- decoder = timeside.decoder.file.FileDecoder(source)
+ decoder = timeside.core.get_processor('file_decoder')(source)
proc = encoder(media, streaming=True, overwrite=True)
if extension in mapping.unavailable_extensions:
metadata=None
source = item.get_source()
if source:
- decoder = timeside.decoder.file.FileDecoder(source)
+ decoder = timeside.core.get_processor('file_decoder')(source)
pipe = decoder
for analyzer in self.value_analyzers: