$ git clone https://github.com/yomguy/TimeSide.git
$ cd TimeSide
$ git checkout dev
- $ export PYTHONPATH=$PYTHONPATH:`pwd`
+ $ sudo pip install -e .
$ python tests/run_all_tests
Sponsors and Partners
'pyyaml',
'simplejson',
'scipy',
+ 'django',
+ 'jsonfield',
],
platforms=['OS Independent'],
license='Gnu Public License V2',
+++ /dev/null
-#!/usr/bin/env python
-import os
-import sys
-
-if __name__ == "__main__":
- os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
-
- from django.core.management import execute_from_command_line
-
- execute_from_command_line(sys.argv)
+++ /dev/null
-# Django settings for server project.
-
-DEBUG = True
-TEMPLATE_DEBUG = DEBUG
-
-import sys
-sys.dont_write_bytecode = True
-
-ADMINS = (
- # ('Your Name', 'your_email@example.com'),
-)
-
-MANAGERS = ADMINS
-
-DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
- 'NAME': 'timeside.sql', # Or path to database file if using sqlite3.
- 'USER': '', # Not used with sqlite3.
- 'PASSWORD': '', # Not used with sqlite3.
- 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
- 'PORT': '', # Set to empty string for default. Not used with sqlite3.
- }
-}
-
-# Hosts/domain names that are valid for this site; required if DEBUG is False
-# See https://docs.djangoproject.com/en/1.4/ref/settings/#allowed-hosts
-ALLOWED_HOSTS = []
-
-# Local time zone for this installation. Choices can be found here:
-# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
-# although not all choices may be available on all operating systems.
-# In a Windows environment this must be set to your system time zone.
-TIME_ZONE = 'America/Chicago'
-
-# Language code for this installation. All choices can be found here:
-# http://www.i18nguy.com/unicode/language-identifiers.html
-LANGUAGE_CODE = 'en-us'
-
-SITE_ID = 1
-
-# If you set this to False, Django will make some optimizations so as not
-# to load the internationalization machinery.
-USE_I18N = True
-
-# If you set this to False, Django will not format dates, numbers and
-# calendars according to the current locale.
-USE_L10N = True
-
-# If you set this to False, Django will not use timezone-aware datetimes.
-USE_TZ = True
-
-# Absolute filesystem path to the directory that will hold user-uploaded files.
-# Example: "/home/media/media.lawrence.com/media/"
-MEDIA_ROOT = ''
-
-# URL that handles the media served from MEDIA_ROOT. Make sure to use a
-# trailing slash.
-# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
-MEDIA_URL = ''
-
-# Absolute path to the directory static files should be collected to.
-# Don't put anything in this directory yourself; store your static files
-# in apps' "static/" subdirectories and in STATICFILES_DIRS.
-# Example: "/home/media/media.lawrence.com/static/"
-STATIC_ROOT = ''
-
-# URL prefix for static files.
-# Example: "http://media.lawrence.com/static/"
-STATIC_URL = '/static/'
-
-# Additional locations of static files
-STATICFILES_DIRS = (
- # Put strings here, like "/home/html/static" or "C:/www/django/static".
- # Always use forward slashes, even on Windows.
- # Don't forget to use absolute paths, not relative paths.
-)
-
-# List of finder classes that know how to find static files in
-# various locations.
-STATICFILES_FINDERS = (
- 'django.contrib.staticfiles.finders.FileSystemFinder',
- 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
-# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
-)
-
-# Make this unique, and don't share it with anybody.
-SECRET_KEY = '5%z&a3r@t0=xr2eaio+400qf-32$b5zp897pr*wh5i^s4(-+3('
-
-# List of callables that know how to import templates from various sources.
-TEMPLATE_LOADERS = (
- 'django.template.loaders.filesystem.Loader',
- 'django.template.loaders.app_directories.Loader',
-# 'django.template.loaders.eggs.Loader',
-)
-
-MIDDLEWARE_CLASSES = (
- 'django.middleware.common.CommonMiddleware',
- 'django.contrib.sessions.middleware.SessionMiddleware',
- 'django.middleware.csrf.CsrfViewMiddleware',
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.messages.middleware.MessageMiddleware',
- # Uncomment the next line for simple clickjacking protection:
- # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
-)
-
-ROOT_URLCONF = 'urls'
-
-# Python dotted path to the WSGI application used by Django's runserver.
-WSGI_APPLICATION = 'wsgi.application'
-
-TEMPLATE_DIRS = (
- # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
- # Always use forward slashes, even on Windows.
- # Don't forget to use absolute paths, not relative paths.
-)
-
-INSTALLED_APPS = (
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.sites',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- # Uncomment the next line to enable the admin:
- 'django.contrib.admin',
- # Uncomment the next line to enable admin documentation:
- # 'django.contrib.admindocs',
- 'south',
- 'timeside',
-)
-
-# A sample logging configuration. The only tangible logging
-# performed by this configuration is to send an email to
-# the site admins on every HTTP 500 error when DEBUG=False.
-# See http://docs.djangoproject.com/en/dev/topics/logging for
-# more details on how to customize your logging configuration.
-LOGGING = {
- 'version': 1,
- 'disable_existing_loggers': False,
- 'filters': {
- 'require_debug_false': {
- '()': 'django.utils.log.RequireDebugFalse'
- }
- },
- 'handlers': {
- 'mail_admins': {
- 'level': 'ERROR',
- 'filters': ['require_debug_false'],
- 'class': 'django.utils.log.AdminEmailHandler'
- }
- },
- 'loggers': {
- 'django.request': {
- 'handlers': ['mail_admins'],
- 'level': 'ERROR',
- 'propagate': True,
- },
- }
-}
+++ /dev/null
-#!/bin/sh
-
-./manage.py schemamigration timeside --auto
-./manage.py migrate timeside
-
+++ /dev/null
-from django.conf.urls import patterns, include, url
-
-# Uncomment the next two lines to enable the admin:
-from django.contrib import admin
-admin.autodiscover()
-
-urlpatterns = patterns('',
-
- url(r'^', include('timeside.urls')),
-
- # Examples:
- # url(r'^$', 'server.views.home', name='home'),
- # url(r'^server/', include('server.foo.urls')),
-
- # Uncomment the admin/doc line below to enable admin documentation:
- # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
-
- # Uncomment the next line to enable the admin:
- url(r'^admin/', include(admin.site.urls)),
-)
+++ /dev/null
-"""
-WSGI config for server project.
-
-This module contains the WSGI application used by Django's development server
-and any production WSGI deployments. It should expose a module-level variable
-named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
-this application via the ``WSGI_APPLICATION`` setting.
-
-Usually you will have the standard Django WSGI application here, but it also
-might make sense to replace the whole Django WSGI application with a custom one
-that later delegates to the Django one. For example, you could introduce WSGI
-middleware here, or combine a Django application with an application of another
-framework.
-
-"""
-import os
-
-os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")
-
-# This application object is used by any WSGI server configured to use this
-# file. This includes Django's development server, if the WSGI_APPLICATION
-# setting points here.
-from django.core.wsgi import get_wsgi_application
-application = get_wsgi_application()
-
-# Apply WSGI middleware here.
-# from helloworld.wsgi import HelloWorldApplication
-# application = HelloWorldApplication(application)
--- /dev/null
+#!/usr/bin/env python
+import os
+import sys
+
+if __name__ == "__main__":
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
+
+ from django.core.management import execute_from_command_line
+
+ execute_from_command_line(sys.argv)
--- /dev/null
+# Django settings for server project.
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+import sys
+sys.dont_write_bytecode = True
+
+ADMINS = (
+ # ('Your Name', 'your_email@example.com'),
+)
+
+MANAGERS = ADMINS
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
+ 'NAME': 'timeside.sql', # Or path to database file if using sqlite3.
+ 'USER': '', # Not used with sqlite3.
+ 'PASSWORD': '', # Not used with sqlite3.
+ 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
+ 'PORT': '', # Set to empty string for default. Not used with sqlite3.
+ }
+}
+
+# Hosts/domain names that are valid for this site; required if DEBUG is False
+# See https://docs.djangoproject.com/en/1.4/ref/settings/#allowed-hosts
+ALLOWED_HOSTS = []
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# In a Windows environment this must be set to your system time zone.
+TIME_ZONE = 'America/Chicago'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'en-us'
+
+SITE_ID = 1
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+
+# If you set this to False, Django will not format dates, numbers and
+# calendars according to the current locale.
+USE_L10N = True
+
+# If you set this to False, Django will not use timezone-aware datetimes.
+USE_TZ = True
+
+# Absolute filesystem path to the directory that will hold user-uploaded files.
+# Example: "/home/media/media.lawrence.com/media/"
+MEDIA_ROOT = ''
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash.
+# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
+MEDIA_URL = ''
+
+# Absolute path to the directory static files should be collected to.
+# Don't put anything in this directory yourself; store your static files
+# in apps' "static/" subdirectories and in STATICFILES_DIRS.
+# Example: "/home/media/media.lawrence.com/static/"
+STATIC_ROOT = ''
+
+# URL prefix for static files.
+# Example: "http://media.lawrence.com/static/"
+STATIC_URL = '/static/'
+
+# Additional locations of static files
+STATICFILES_DIRS = (
+ # Put strings here, like "/home/html/static" or "C:/www/django/static".
+ # Always use forward slashes, even on Windows.
+ # Don't forget to use absolute paths, not relative paths.
+)
+
+# List of finder classes that know how to find static files in
+# various locations.
+STATICFILES_FINDERS = (
+ 'django.contrib.staticfiles.finders.FileSystemFinder',
+ 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
+)
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = '5%z&a3r@t0=xr2eaio+400qf-32$b5zp897pr*wh5i^s4(-+3('
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader',
+# 'django.template.loaders.eggs.Loader',
+)
+
+MIDDLEWARE_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ # Uncomment the next line for simple clickjacking protection:
+ # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+)
+
+ROOT_URLCONF = 'urls'
+
+# Python dotted path to the WSGI application used by Django's runserver.
+WSGI_APPLICATION = 'wsgi.application'
+
+TEMPLATE_DIRS = (
+ # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
+ # Always use forward slashes, even on Windows.
+ # Don't forget to use absolute paths, not relative paths.
+)
+
+INSTALLED_APPS = (
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+ # Uncomment the next line to enable the admin:
+ 'django.contrib.admin',
+ # Uncomment the next line to enable admin documentation:
+ # 'django.contrib.admindocs',
+ 'django_extensions',
+ 'south',
+ 'timeside',
+)
+
+# A sample logging configuration. The only tangible logging
+# performed by this configuration is to send an email to
+# the site admins on every HTTP 500 error when DEBUG=False.
+# See http://docs.djangoproject.com/en/dev/topics/logging for
+# more details on how to customize your logging configuration.
+LOGGING = {
+ 'version': 1,
+ 'disable_existing_loggers': False,
+ 'filters': {
+ 'require_debug_false': {
+ '()': 'django.utils.log.RequireDebugFalse'
+ }
+ },
+ 'handlers': {
+ 'mail_admins': {
+ 'level': 'ERROR',
+ 'filters': ['require_debug_false'],
+ 'class': 'django.utils.log.AdminEmailHandler'
+ }
+ },
+ 'loggers': {
+ 'django.request': {
+ 'handlers': ['mail_admins'],
+ 'level': 'ERROR',
+ 'propagate': True,
+ },
+ }
+}
--- /dev/null
+#!/bin/sh
+
+./manage.py schemamigration timeside --auto
+./manage.py migrate timeside
+
--- /dev/null
+from django.conf.urls import patterns, include, url
+
+# Uncomment the next two lines to enable the admin:
+from django.contrib import admin
+admin.autodiscover()
+
+urlpatterns = patterns('',
+
+ url(r'^', include('timeside.urls')),
+
+ # Examples:
+ # url(r'^$', 'server.views.home', name='home'),
+ # url(r'^server/', include('server.foo.urls')),
+
+ # Uncomment the admin/doc line below to enable admin documentation:
+ # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
+
+ # Uncomment the next line to enable the admin:
+ url(r'^admin/', include(admin.site.urls)),
+)
--- /dev/null
+"""
+WSGI config for server project.
+
+This module contains the WSGI application used by Django's development server
+and any production WSGI deployments. It should expose a module-level variable
+named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
+this application via the ``WSGI_APPLICATION`` setting.
+
+Usually you will have the standard Django WSGI application here, but it also
+might make sense to replace the whole Django WSGI application with a custom one
+that later delegates to the Django one. For example, you could introduce WSGI
+middleware here, or combine a Django application with an application of another
+framework.
+
+"""
+import os
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")
+
+# This application object is used by any WSGI server configured to use this
+# file. This includes Django's development server, if the WSGI_APPLICATION
+# setting points here.
+from django.core.wsgi import get_wsgi_application
+application = get_wsgi_application()
+
+# Apply WSGI middleware here.
+# from helloworld.wsgi import HelloWorldApplication
+# application = HelloWorldApplication(application)
class Migration(SchemaMigration):
def forwards(self, orm):
+ # Adding model 'Collection'
+ db.create_table('timeside_collections', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('code', self.gf('django.db.models.fields.CharField')(unique=True, max_length=512)),
+ ('title', self.gf('django.db.models.fields.CharField')(max_length=512, blank=True)),
+ ('description', self.gf('django.db.models.fields.TextField')(blank=True)),
+ ))
+ db.send_create_signal('timeside', ['Collection'])
+
+ # Adding M2M table for field items on 'Collection'
+ m2m_table_name = db.shorten_name('timeside_collections_items')
+ db.create_table(m2m_table_name, (
+ ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
+ ('collection', models.ForeignKey(orm['timeside.collection'], null=False)),
+ ('item', models.ForeignKey(orm['timeside.item'], null=False))
+ ))
+ db.create_unique(m2m_table_name, ['collection_id', 'item_id'])
+
# Adding model 'Item'
db.create_table('timeside_items', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
))
db.send_create_signal('timeside', ['Item'])
- # Adding model 'Analyzer'
- db.create_table('timeside_analyzers', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('pid', self.gf('django.db.models.fields.CharField')(max_length=256)),
- ('parameters', self.gf('django.db.models.fields.TextField')(blank=True)),
- ('version', self.gf('django.db.models.fields.CharField')(max_length=64, blank=True)),
- ('status', self.gf('django.db.models.fields.IntegerField')(default=1)),
- ))
- db.send_create_signal('timeside', ['Analyzer'])
-
- # Adding model 'Grapher'
- db.create_table('timeside_graphers', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('pid', self.gf('django.db.models.fields.CharField')(max_length=256)),
- ('parameters', self.gf('django.db.models.fields.TextField')(blank=True)),
- ('version', self.gf('django.db.models.fields.CharField')(max_length=64, blank=True)),
- ('status', self.gf('django.db.models.fields.IntegerField')(default=1)),
- ('file', self.gf('django.db.models.fields.files.FileField')(max_length=1024, db_column='file')),
- ('mime_type', self.gf('django.db.models.fields.CharField')(max_length=256, null=True)),
- ('height', self.gf('django.db.models.fields.IntegerField')(default=180)),
- ('width', self.gf('django.db.models.fields.IntegerField')(default=320)),
- ))
- db.send_create_signal('timeside', ['Grapher'])
-
- # Adding model 'Encoder'
- db.create_table('timeside_encoders', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('pid', self.gf('django.db.models.fields.CharField')(max_length=256)),
- ('parameters', self.gf('django.db.models.fields.TextField')(blank=True)),
- ('version', self.gf('django.db.models.fields.CharField')(max_length=64, blank=True)),
- ('status', self.gf('django.db.models.fields.IntegerField')(default=1)),
- ('file', self.gf('django.db.models.fields.files.FileField')(max_length=1024, db_column='file')),
- ('mime_type', self.gf('django.db.models.fields.CharField')(max_length=256, null=True)),
+ # Adding M2M table for field experiences on 'Item'
+ m2m_table_name = db.shorten_name('timeside_items_experiences')
+ db.create_table(m2m_table_name, (
+ ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
+ ('item', models.ForeignKey(orm['timeside.item'], null=False)),
+ ('experience', models.ForeignKey(orm['timeside.experience'], null=False))
))
- db.send_create_signal('timeside', ['Encoder'])
+ db.create_unique(m2m_table_name, ['item_id', 'experience_id'])
# Adding model 'Experience'
db.create_table('timeside_experiences', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('item', self.gf('django.db.models.fields.related.ForeignKey')(related_name='experience', null=True, on_delete=models.SET_NULL, to=orm['timeside.Item'])),
('title', self.gf('django.db.models.fields.CharField')(max_length=512, blank=True)),
('description', self.gf('django.db.models.fields.TextField')(blank=True)),
('date_added', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
('date_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, null=True, blank=True)),
('status', self.gf('django.db.models.fields.IntegerField')(default=1)),
- ('uuid', self.gf('django.db.models.fields.CharField')(max_length=256)),
- ('author', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='experience', null=True, to=orm['auth.User'])),
- ('begin_time', self.gf('django.db.models.fields.FloatField')(default=0, blank=True)),
- ('end_time', self.gf('django.db.models.fields.FloatField')(blank=True)),
- ('low_frequency', self.gf('django.db.models.fields.FloatField')(blank=True)),
- ('high_frequency', self.gf('django.db.models.fields.FloatField')(blank=True)),
- ('hdf5', self.gf('django.db.models.fields.files.FileField')(max_length=1024, db_column='hdf5')),
+ ('uuid', self.gf('django.db.models.fields.CharField')(max_length=512)),
+ ('author', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='experience', null=True, on_delete=models.SET_NULL, to=orm['auth.User'])),
))
db.send_create_signal('timeside', ['Experience'])
- # Adding M2M table for field analyzers on 'Experience'
- m2m_table_name = db.shorten_name('timeside_experiences_analyzers')
+ # Adding M2M table for field processors on 'Experience'
+ m2m_table_name = db.shorten_name('timeside_experiences_processors')
db.create_table(m2m_table_name, (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('experience', models.ForeignKey(orm['timeside.experience'], null=False)),
- ('analyzer', models.ForeignKey(orm['timeside.analyzer'], null=False))
+ ('processor', models.ForeignKey(orm['timeside.processor'], null=False))
))
- db.create_unique(m2m_table_name, ['experience_id', 'analyzer_id'])
+ db.create_unique(m2m_table_name, ['experience_id', 'processor_id'])
- # Adding M2M table for field graphers on 'Experience'
- m2m_table_name = db.shorten_name('timeside_experiences_graphers')
- db.create_table(m2m_table_name, (
- ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
- ('experience', models.ForeignKey(orm['timeside.experience'], null=False)),
- ('grapher', models.ForeignKey(orm['timeside.grapher'], null=False))
- ))
- db.create_unique(m2m_table_name, ['experience_id', 'grapher_id'])
-
- # Adding M2M table for field encoders on 'Experience'
- m2m_table_name = db.shorten_name('timeside_experiences_encoders')
- db.create_table(m2m_table_name, (
- ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
- ('experience', models.ForeignKey(orm['timeside.experience'], null=False)),
- ('encoder', models.ForeignKey(orm['timeside.encoder'], null=False))
+ # Adding model 'Processor'
+ db.create_table('timeside_processors', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('pid', self.gf('django.db.models.fields.CharField')(max_length=256)),
+ ('type', self.gf('django.db.models.fields.CharField')(default='none', max_length=64)),
+ ('parameters', self.gf('jsonfield.fields.JSONField')(blank=True)),
+ ('version', self.gf('django.db.models.fields.CharField')(max_length=64, blank=True)),
+ ('uuid', self.gf('django.db.models.fields.CharField')(max_length=512)),
+ ('status', self.gf('django.db.models.fields.IntegerField')(default=1)),
+ ('file', self.gf('django.db.models.fields.files.FileField')(max_length=1024, db_column='file')),
+ ('mime_type', self.gf('django.db.models.fields.CharField')(max_length=256, null=True)),
+ ('results', self.gf('jsonfield.fields.JSONField')(blank=True)),
))
- db.create_unique(m2m_table_name, ['experience_id', 'encoder_id'])
+ db.send_create_signal('timeside', ['Processor'])
def backwards(self, orm):
- # Deleting model 'Item'
- db.delete_table('timeside_items')
+ # Deleting model 'Collection'
+ db.delete_table('timeside_collections')
- # Deleting model 'Analyzer'
- db.delete_table('timeside_analyzers')
+ # Removing M2M table for field items on 'Collection'
+ db.delete_table(db.shorten_name('timeside_collections_items'))
- # Deleting model 'Grapher'
- db.delete_table('timeside_graphers')
+ # Deleting model 'Item'
+ db.delete_table('timeside_items')
- # Deleting model 'Encoder'
- db.delete_table('timeside_encoders')
+ # Removing M2M table for field experiences on 'Item'
+ db.delete_table(db.shorten_name('timeside_items_experiences'))
# Deleting model 'Experience'
db.delete_table('timeside_experiences')
- # Removing M2M table for field analyzers on 'Experience'
- db.delete_table(db.shorten_name('timeside_experiences_analyzers'))
-
- # Removing M2M table for field graphers on 'Experience'
- db.delete_table(db.shorten_name('timeside_experiences_graphers'))
+ # Removing M2M table for field processors on 'Experience'
+ db.delete_table(db.shorten_name('timeside_experiences_processors'))
- # Removing M2M table for field encoders on 'Experience'
- db.delete_table(db.shorten_name('timeside_experiences_encoders'))
+ # Deleting model 'Processor'
+ db.delete_table('timeside_processors')
models = {
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
- 'timeside.analyzer': {
- 'Meta': {'object_name': 'Analyzer', 'db_table': "'timeside_analyzers'"},
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'parameters': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'pid': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
- 'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
- 'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'})
- },
- 'timeside.encoder': {
- 'Meta': {'object_name': 'Encoder', 'db_table': "'timeside_encoders'"},
- 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '1024', 'db_column': "'file'"}),
+ 'timeside.collection': {
+ 'Meta': {'ordering': "['code']", 'object_name': 'Collection', 'db_table': "'timeside_collections'"},
+ 'code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '512'}),
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'mime_type': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True'}),
- 'parameters': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'pid': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
- 'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
- 'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'})
+ 'items': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'collections'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['timeside.Item']"}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '512', 'blank': 'True'})
},
'timeside.experience': {
'Meta': {'object_name': 'Experience', 'db_table': "'timeside_experiences'"},
- 'analyzers': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'experience'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['timeside.Analyzer']"}),
- 'author': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'experience'", 'null': 'True', 'to': "orm['auth.User']"}),
- 'begin_time': ('django.db.models.fields.FloatField', [], {'default': '0', 'blank': 'True'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'experience'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['auth.User']"}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'date_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'null': 'True', 'blank': 'True'}),
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'encoders': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'experience'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['timeside.Encoder']"}),
- 'end_time': ('django.db.models.fields.FloatField', [], {'blank': 'True'}),
- 'graphers': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'experience'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['timeside.Grapher']"}),
- 'hdf5': ('django.db.models.fields.files.FileField', [], {'max_length': '1024', 'db_column': "'hdf5'"}),
- 'high_frequency': ('django.db.models.fields.FloatField', [], {'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'item': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'experience'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['timeside.Item']"}),
- 'low_frequency': ('django.db.models.fields.FloatField', [], {'blank': 'True'}),
+ 'processors': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'experience'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['timeside.Processor']"}),
'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '512', 'blank': 'True'}),
- 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '256'})
- },
- 'timeside.grapher': {
- 'Meta': {'object_name': 'Grapher', 'db_table': "'timeside_graphers'"},
- 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '1024', 'db_column': "'file'"}),
- 'height': ('django.db.models.fields.IntegerField', [], {'default': '180'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'mime_type': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True'}),
- 'parameters': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'pid': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
- 'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
- 'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
- 'width': ('django.db.models.fields.IntegerField', [], {'default': '320'})
+ 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '512'})
},
'timeside.item': {
'Meta': {'ordering': "['code']", 'object_name': 'Item', 'db_table': "'timeside_items'"},
'code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '512'}),
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'experiences': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'items'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['timeside.Experience']"}),
'file': ('django.db.models.fields.files.FileField', [], {'max_length': '1024', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'mime_type': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True'}),
'sha1': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '512', 'blank': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '512', 'blank': 'True'}),
'url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'blank': 'True'})
+ },
+ 'timeside.processor': {
+ 'Meta': {'object_name': 'Processor', 'db_table': "'timeside_processors'"},
+ 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '1024', 'db_column': "'file'"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'mime_type': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True'}),
+ 'parameters': ('jsonfield.fields.JSONField', [], {'blank': 'True'}),
+ 'pid': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+ 'results': ('jsonfield.fields.JSONField', [], {'blank': 'True'}),
+ 'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
+ 'type': ('django.db.models.fields.CharField', [], {'default': "'none'", 'max_length': '64'}),
+ 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
+ 'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'})
}
}
+++ /dev/null
-# -*- coding: utf-8 -*-
-from south.utils import datetime_utils as datetime
-from south.db import db
-from south.v2 import SchemaMigration
-from django.db import models
-
-
-class Migration(SchemaMigration):
-
- def forwards(self, orm):
- # Adding model 'Decoder'
- db.create_table('timeside_decoders', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('pid', self.gf('django.db.models.fields.CharField')(max_length=256)),
- ('parameters', self.gf('django.db.models.fields.TextField')(blank=True)),
- ('version', self.gf('django.db.models.fields.CharField')(max_length=64, blank=True)),
- ('status', self.gf('django.db.models.fields.IntegerField')(default=1)),
- ))
- db.send_create_signal('timeside', ['Decoder'])
-
- # Adding field 'Experience.decoder'
- db.add_column('timeside_experiences', 'decoder',
- self.gf('django.db.models.fields.related.ForeignKey')(related_name='experience', null=True, to=orm['timeside.Decoder']),
- keep_default=False)
-
- # Adding field 'Experience.json'
- db.add_column('timeside_experiences', 'json',
- self.gf('django.db.models.fields.files.FileField')(default=1, max_length=1024, db_column='json'),
- keep_default=False)
-
-
- def backwards(self, orm):
- # Deleting model 'Decoder'
- db.delete_table('timeside_decoders')
-
- # Deleting field 'Experience.decoder'
- db.delete_column('timeside_experiences', 'decoder_id')
-
- # Deleting field 'Experience.json'
- db.delete_column('timeside_experiences', 'json')
-
-
- models = {
- 'auth.group': {
- 'Meta': {'object_name': 'Group'},
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
- 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
- },
- 'auth.permission': {
- 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
- 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
- },
- 'auth.user': {
- 'Meta': {'object_name': 'User'},
- 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
- 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
- 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
- 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
- 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
- },
- 'contenttypes.contenttype': {
- 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
- 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
- },
- 'timeside.analyzer': {
- 'Meta': {'object_name': 'Analyzer', 'db_table': "'timeside_analyzers'"},
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'parameters': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'pid': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
- 'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
- 'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'})
- },
- 'timeside.decoder': {
- 'Meta': {'object_name': 'Decoder', 'db_table': "'timeside_decoders'"},
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'parameters': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'pid': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
- 'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
- 'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'})
- },
- 'timeside.encoder': {
- 'Meta': {'object_name': 'Encoder', 'db_table': "'timeside_encoders'"},
- 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '1024', 'db_column': "'file'"}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'mime_type': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True'}),
- 'parameters': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'pid': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
- 'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
- 'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'})
- },
- 'timeside.experience': {
- 'Meta': {'object_name': 'Experience', 'db_table': "'timeside_experiences'"},
- 'analyzers': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'experience'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['timeside.Analyzer']"}),
- 'author': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'experience'", 'null': 'True', 'to': "orm['auth.User']"}),
- 'begin_time': ('django.db.models.fields.FloatField', [], {'default': '0', 'blank': 'True'}),
- 'date_added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
- 'date_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'null': 'True', 'blank': 'True'}),
- 'decoder': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'experience'", 'null': 'True', 'to': "orm['timeside.Decoder']"}),
- 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'encoders': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'experience'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['timeside.Encoder']"}),
- 'end_time': ('django.db.models.fields.FloatField', [], {'blank': 'True'}),
- 'graphers': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'experience'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['timeside.Grapher']"}),
- 'hdf5': ('django.db.models.fields.files.FileField', [], {'max_length': '1024', 'db_column': "'hdf5'"}),
- 'high_frequency': ('django.db.models.fields.FloatField', [], {'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'item': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'experience'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['timeside.Item']"}),
- 'json': ('django.db.models.fields.files.FileField', [], {'max_length': '1024', 'db_column': "'json'"}),
- 'low_frequency': ('django.db.models.fields.FloatField', [], {'blank': 'True'}),
- 'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
- 'title': ('django.db.models.fields.CharField', [], {'max_length': '512', 'blank': 'True'}),
- 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '256'})
- },
- 'timeside.grapher': {
- 'Meta': {'object_name': 'Grapher', 'db_table': "'timeside_graphers'"},
- 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '1024', 'db_column': "'file'"}),
- 'height': ('django.db.models.fields.IntegerField', [], {'default': '180'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'mime_type': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True'}),
- 'parameters': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'pid': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
- 'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
- 'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
- 'width': ('django.db.models.fields.IntegerField', [], {'default': '320'})
- },
- 'timeside.item': {
- 'Meta': {'ordering': "['code']", 'object_name': 'Item', 'db_table': "'timeside_items'"},
- 'code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '512'}),
- 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '1024', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'mime_type': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True'}),
- 'sha1': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '512', 'blank': 'True'}),
- 'title': ('django.db.models.fields.CharField', [], {'max_length': '512', 'blank': 'True'}),
- 'url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'blank': 'True'})
- }
- }
-
- complete_apps = ['timeside']
\ No newline at end of file
# -*- coding: utf-8 -*-
from django.db.models import *
+from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User
+import uuid
import timeside
+from timeside.analyzer.core import AnalyzerResultContainer
+from jsonfield import JSONField
+
+
app = 'timeside'
+processors = timeside.core.processors(timeside.api.IProcessor)
+
STATUS = ((0, _('broken')), (1, _('pending')), (2, _('processing')),
(3, _('done')), (4, _('ready')))
+PROCESSOR_TYPES = (('none', _('none')), ('decoder', _('decoder')), ('analyzer', _('analyzer')),
+ ('grapher', _('grapher')), ('encoder', _('encoder')))
+
+
+def get_mime_type(self, path):
+ return mimetypes.guess_type(path)[0]
+
+
+def get_processor(self, pid):
+ for proc in processors:
+ if proc.id == pid:
+ return proc()
+ raise ValueError('Processor %s does not exists' % pid)
+
+
class MetaCore:
app_label = app
+class Collection(Model):
+
+ code = CharField(_('code'), unique=True, max_length=512)
+ title = CharField(_('title'), blank=True, max_length=512)
+ description = TextField(_('description'), blank=True)
+ items = ManyToManyField('Item', related_name="collections", verbose_name=_('items'), blank=True, null=True)
+
+ class Meta(MetaCore):
+ db_table = app + '_collections'
+ ordering = ['code']
+ verbose_name = _('collections')
+
+
class Item(Model):
code = CharField(_('code'), unique=True, max_length=512)
title = CharField(_('title'), blank=True, max_length=512)
- description = TextField(_('description'), blank=True)
+ description = TextField(_('description'), blank=True)
file = FileField(_('file'), upload_to='items/%Y/%m/%d', blank=True, max_length=1024)
url = URLField(_('URL'), blank=True, max_length=1024)
sha1 = CharField(_('sha1'), unique=True, blank=True, max_length=512)
- mime_type = CharField(_('mime_type'), null=True, max_length=256)
-
- def set_mime_type(self):
- if self.file:
- self.mime_type = mimetypes.guess_type(self.file.path)[0]
+ mime_type = CharField(_('mime type'), null=True, max_length=256)
+ experiences = ManyToManyField('Experience', related_name="items", verbose_name=_('experiences'), blank=True, null=True)
class Meta(MetaCore):
db_table = app + '_items'
def __unicode__(self):
return self.code
-
-class Processor(Model):
-
- pid = CharField(_('pid'), max_length=256)
- parameters = TextField(_('parameters'), blank=True)
- version = CharField(_('version'), max_length=64, blank=True)
- status = IntegerField(_('status'), choices=STATUS, default=1)
-
- def save(self):
- super(Processor, self).save()
- if not self.version:
- self.version = timeside.__version__
-
- class Meta(MetaCore):
- abstract=True
-
-
-class Decoder(Processor):
-
- class Meta(MetaCore):
- db_table = app + '_decoders'
- verbose_name = _('decoder')
-
-
-class Analyzer(Processor):
-
- class Meta(MetaCore):
- db_table = app + '_analyzers'
- verbose_name = _('analyzer')
-
-
-class Grapher(Processor):
-
- file = FileField(_('file'), upload_to='cache/grapher/%Y/%m/%d', db_column="file", max_length=1024)
- mime_type = CharField(_('mime_type'), null=True, max_length=256)
- height = IntegerField(_('height'), default=180)
- width = IntegerField(_('width'), default=320)
-
- class Meta(MetaCore):
- db_table = app + '_graphers'
- verbose_name = _('grapher')
-
-
-class Encoder(Processor):
-
- file = FileField(_('file'), upload_to='cache/encoder/%Y/%m/%d', db_column="file", max_length=1024)
- mime_type = CharField(_('mime_type'), null=True, max_length=256)
-
- class Meta(MetaCore):
- db_table = app + '_encoders'
- verbose_name = _('encoder')
+ def save(self, **kwargs):
+ super(Item, self).save(**kwargs)
+ if self.file:
+ self.mime_type = get_mime_type(self.file.path)
class Experience(Model):
- item = ForeignKey(Item, related_name='experience', verbose_name=_('item'), null=True, on_delete=SET_NULL)
title = CharField(_('title'), blank=True, max_length=512)
description = TextField(_('description'), blank=True)
date_added = DateTimeField(_('date added'), auto_now_add=True)
date_modified = DateTimeField(_('date modified'), auto_now=True, null=True)
status = IntegerField(_('status'), choices=STATUS, default=1)
- uuid = CharField(_('uuid'), max_length=256)
- author = ForeignKey(User, related_name="experience", verbose_name=_('author'), blank=True, null=True)
-
- decoder = ForeignKey(Decoder, related_name="experience", verbose_name=_('decoder'), null=True)
- analyzers = ManyToManyField(Analyzer, related_name="experience", verbose_name=_('analyzers'), blank=True, null=True)
- graphers = ManyToManyField(Grapher, related_name="experience", verbose_name=_('graphers'), blank=True, null=True)
- encoders = ManyToManyField(Encoder, related_name="experience", verbose_name=_('encoders'), blank=True, null=True)
-
- begin_time = FloatField(_('begin time'), default=0, blank=True)
- end_time = FloatField(_('end time'), blank=True)
- low_frequency = FloatField(_('low frequency'), blank=True)
- high_frequency = FloatField(_('highh frequency'), blank=True)
-
- hdf5 = FileField(_('hdf5_file'), upload_to='cache/hdf5/%Y/%m/%d', db_column="hdf5", max_length=1024)
- json = FileField(_('json_file'), upload_to='cache/json/%Y/%m/%d', db_column="json", max_length=1024)
-
+ uuid = CharField(_('uuid'), max_length=512)
+ author = ForeignKey(User, related_name="experience", verbose_name=_('author'), blank=True, null=True, on_delete=models.SET_NULL)
+ processors = ManyToManyField('Processor', related_name="experience", verbose_name=_('processors'), blank=True, null=True)
+
class Meta(MetaCore):
db_table = app + '_experiences'
verbose_name = _('experience')
- def results(self):
- pass
+ def save(self, **kwargs):
+ super(Experience, self).save(**kwargs)
+ if not self.uuid:
+ self.uuid = uuid.uuid4()
+
+ def run(self, collection):
+ for item in collections.item.all():
+ item.experiences.add(self)
+ pipe = FileDecoder(item.file)
+ proc_dict = {}
+ for processor in self.processors:
+ proc = get_processor(processor.id)
+ #TODO: add parameters
+ proc_dict[processor] = proc
+ pipe = pipe | proc
+ pipe.run()
+ for processor in proc_dict.keys():
+ processor.file = settings.MEDIA_ROOT + processor.uuid + '.' + processor.mime_type.split('/')[1]
+ proc_dict[processor].results.to_hdf5(processor.file)
+ processor.save()
+ del pipe
+
+class Processor(Model):
+
+ pid = CharField(_('pid'), max_length=256)
+ type = CharField(_('type'), choices=PROCESSOR_TYPES, default='none', max_length=64)
+ parameters = JSONField(_('parameters'), blank=True)
+ version = CharField(_('version'), max_length=64, blank=True)
+ uuid = CharField(_('uuid'), max_length=512)
+ status = IntegerField(_('status'), choices=STATUS, default=1)
+ file = FileField(_('file'), upload_to='cache/%Y/%m/%d', db_column="file", max_length=1024)
+ mime_type = CharField(_('mime type'), null=True, max_length=256)
+ results = JSONField(_('results'), blank=True)
+
+ class Meta(MetaCore):
+ db_table = app + '_processors'
+ verbose_name = _('processor')
+
+ def save(self, **kwargs):
+ super(Processor, self).save(**kwargs)
+ if not self.version:
+ self.version = timeside.__version__
+ if self.file:
+ self.mime_type = get_mime_type(self.file.path)
+ if not self.uuid:
+ self.uuid = uuid.uuid4()
from timeside.models import *
-decoders = timeside.core.processors(timeside.api.IDecoder)
-analyzers = timeside.core.processors(timeside.api.IAnalyzer)
-graphers = timeside.core.processors(timeside.api.IGrapher)
-encoders = timeside.core.processors(timeside.api.IEncoder)
-value_analyzers = timeside.core.processors(timeside.api.IValueAnalyzer)
+def stream_from_file(__file):
+ chunk_size = 0x10000
+ f = open(__file, 'r')
+ while True:
+ __chunk = f.read(chunk_size)
+ if not len(__chunk):
+ f.close()
+ break
+ yield __chunk
class IndexView(ListView):
class ItemGrapherView(DetailView):
model = Item
+ mime_type = 'image/png'
+
+class ItemJsonAnalyzerView(DetailView):
+
+ model = Item
+
+ def results(self):
+ item = self.get_object()
+ experience = Experience.objects.get(id=experience_id)
+ results = AnalyzerResult()
+ return results.from_hdf5(self.hdf5).to_json()
+
+ def get_context_data(self, **kwargs):
+ context = super(ItemJsonAnalyzerView, self).get_context_data(**kwargs)
+ item = self.get_object()
+ context['experiences'] = item.experiences.all().filter(author=self.request.user)
+ return context
+
+ def render_to_response(self, context):
+ mimetype = mimetypes.guess_type(document.file.path)[0]
+ extension = mimetypes.guess_extension(mimetype)
+ response = HttpResponse(results, mimetype=mimetype)
+ response['Content-Disposition'] = "attachment; filename=%s%s" % \
+ (document.title.encode('utf8'), extension)
+ return response
+
+ @jsonrpc_method('timeside.stop_conference'):
+ def stop(request, public_id):