diff --git a/pandora/app/config.py b/pandora/app/config.py index 3ab3d462b..672c4a3bc 100644 --- a/pandora/app/config.py +++ b/pandora/app/config.py @@ -375,13 +375,3 @@ def update_geoip(force=False): def init(): load_config(True) - -def shutdown(): - if settings.RELOADER_RUNNING: - RUN_RELOADER = False - settings.RELOADER_RUNNING = False - if NOTIFIER: - NOTIFIER.stop() - - - diff --git a/pandora/archive/extract.py b/pandora/archive/extract.py index 6bb3acc1a..1ddbd69e7 100644 --- a/pandora/archive/extract.py +++ b/pandora/archive/extract.py @@ -1,16 +1,17 @@ # -*- coding: utf-8 -*- -import os +from distutils.spawn import find_executable +from glob import glob from os.path import exists import fractions +import logging import math +import os import re import shutil import subprocess import tempfile import time -from distutils.spawn import find_executable -from glob import glob import numpy as np import ox @@ -21,6 +22,9 @@ from PIL import Image from .chop import Chop, make_keyframe_index + +logger = logging.getLogger('pandora.' + __name__) + img_extension = 'jpg' MAX_DISTANCE = math.sqrt(3 * pow(255, 2)) diff --git a/pandora/archive/models.py b/pandora/archive/models.py index 70077cfad..a5800d3df 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -832,7 +832,7 @@ class Stream(models.Model): # get current version from db and update try: self.refresh_from_db() - except archive.models.DoesNotExist: + except Stream.DoesNotExist: pass else: self.update_status(ok, error) diff --git a/pandora/archive/queue.py b/pandora/archive/queue.py index edae2c428..7cb768b2b 100644 --- a/pandora/archive/queue.py +++ b/pandora/archive/queue.py @@ -65,7 +65,7 @@ def fill_queue(): def get_celery_worker_status(): ERROR_KEY = "ERROR" try: - insp = celery.task.control.inspect() + insp = app.control.inspect() d = insp.stats() if not d: d = {ERROR_KEY: 'No running Celery workers were found.'} diff --git a/pandora/document/managers/__init__.py b/pandora/document/managers/__init__.py index 06d7fa718..edcc4789e 100644 --- a/pandora/document/managers/__init__.py +++ b/pandora/document/managers/__init__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from datetime import datetime import unicodedata from django.db.models import Q, Manager diff --git a/pandora/document/managers/pages.py b/pandora/document/managers/pages.py index 5a3a4ab7d..2fbfa4fe6 100644 --- a/pandora/document/managers/pages.py +++ b/pandora/document/managers/pages.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from datetime import datetime import unicodedata from six import string_types diff --git a/pandora/document/models.py b/pandora/document/models.py index 326b93872..d60bd27bb 100644 --- a/pandora/document/models.py +++ b/pandora/document/models.py @@ -6,11 +6,12 @@ import os import re import unicodedata +from django.conf import settings +from django.contrib.auth import get_user_model from django.db import models, transaction from django.db.models import Q, Sum, Max -from django.contrib.auth import get_user_model from django.db.models.signals import pre_delete -from django.conf import settings +from django.utils import datetime_safe from oxdjango.fields import JSONField from PIL import Image @@ -79,7 +80,7 @@ class Document(models.Model, FulltextMixin): current_values = [] for k in settings.CONFIG['documentKeys']: if k.get('sortType') == 'person': - current_values += self.get(k['id'], []) + current_values += self.get_value(k['id'], []) if not isinstance(current_values, list): if not current_values: current_values = [] diff --git a/pandora/document/page_views.py b/pandora/document/page_views.py index d1a0224ca..d0ae7c0bc 100644 --- a/pandora/document/page_views.py +++ b/pandora/document/page_views.py @@ -60,6 +60,25 @@ def _order_query(qs, sort): qs = qs.distinct() return qs +def _order_by_group(query): + prefix = 'document__sort__' + if 'sort' in query: + op = '-' if query['sort'][0]['operator'] == '-' else '' + if len(query['sort']) == 1 and query['sort'][0]['key'] == 'items': + order_by = op + prefix + 'items' + if query['group'] == "year": + secondary = op + prefix + 'sortvalue' + order_by = (order_by, secondary) + elif query['group'] != "keyword": + order_by = (order_by, prefix + 'sortvalue') + else: + order_by = (order_by, 'value') + else: + order_by = op + prefix + 'sortvalue' + order_by = (order_by, prefix + 'items') + else: + order_by = ('-' + prefix + 'sortvalue', prefix + 'items') + return order_by def findPages(request, data): ''' diff --git a/pandora/edit/views.py b/pandora/edit/views.py index d4bccf825..4de8679d8 100644 --- a/pandora/edit/views.py +++ b/pandora/edit/views.py @@ -3,14 +3,16 @@ import os import re -import ox +from oxdjango.api import actions from oxdjango.decorators import login_required_json +from oxdjango.http import HttpFileResponse from oxdjango.shortcuts import render_to_json_response, get_object_or_404_json, json_response +import ox + +from django.conf import settings from django.db import transaction from django.db.models import Max -from oxdjango.http import HttpFileResponse -from oxdjango.api import actions -from django.conf import settings +from django.db.models import Sum from item import utils from changelog.models import add_changelog diff --git a/pandora/item/models.py b/pandora/item/models.py index 2172723e5..f6d992c0a 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -1209,7 +1209,7 @@ class Item(models.Model): if not r: return False path = video.name - duration = sum(item.cache['durations']) + duration = sum(self.item.cache['durations']) else: path = stream.media.path duration = stream.info['duration'] diff --git a/pandora/item/views.py b/pandora/item/views.py index afc922580..8ad2db2e0 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -16,12 +16,14 @@ from wsgiref.util import FileWrapper from django.conf import settings from ox.utils import json, ET - -from oxdjango.decorators import login_required_json -from oxdjango.shortcuts import render_to_json_response, get_object_or_404_json, json_response -from oxdjango.http import HttpFileResponse import ox +from oxdjango.api import actions +from oxdjango.decorators import login_required_json +from oxdjango.http import HttpFileResponse +from oxdjango.shortcuts import render_to_json_response, get_object_or_404_json, json_response +import oxdjango + from . import models from . import utils from . import tasks @@ -32,7 +34,6 @@ from clip.models import Clip from user.models import has_capability from changelog.models import add_changelog -from oxdjango.api import actions def _order_query(qs, sort, prefix='sort__'): @@ -595,7 +596,7 @@ def add(request, data): if p: p.wait() else: - i.make_poster() + item.make_poster() del data['title'] if data: response = edit_item(request.user, item, data) diff --git a/pandora/news/managers.py b/pandora/news/managers.py index bb1f242d1..213d5ee18 100644 --- a/pandora/news/managers.py +++ b/pandora/news/managers.py @@ -11,7 +11,7 @@ keymap = { default_key = 'name' def parseCondition(condition, user): - k = condition.get('key', defauly_key) + k = condition.get('key', default_key) k = keymap.get(k, k) if not k: k = default_key