Compare commits

..

3 commits

Author SHA1 Message Date
j
774450d263 missing imports and typos 2024-04-05 21:20:45 +01:00
j
e1a28c941a fix country fallback 2024-04-05 21:20:15 +01:00
j
c55c733bcd celery fixes 2024-04-05 21:19:57 +01:00
16 changed files with 53 additions and 46 deletions

View file

@ -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()

View file

@ -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))

View file

@ -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)

View file

@ -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.'}

View file

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from datetime import datetime
import unicodedata
from django.db.models import Q, Manager

View file

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from datetime import datetime
import unicodedata
from six import string_types

View file

@ -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 = []

View file

@ -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):
'''

View file

@ -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

View file

@ -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']

View file

@ -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)

View file

@ -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

View file

@ -167,7 +167,7 @@ class Task(models.Model):
job = self.get_job()
if job:
print(job)
r = celery.task.control.revoke(job['id'])
r = app.control.revoke(job['id'])
print(r)
for f in self.item.files.filter(encoding=True):
f.delete()

View file

@ -1,12 +0,0 @@
# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
urlpatterns = patterns("user.views",
(r'^preferences', 'preferences'),
(r'^login', 'login'),
(r'^logout', 'logout'),
(r'^register', 'register'),
)

View file

@ -24,7 +24,7 @@ def get_location(ip):
location = g.city(ip)
except:
try:
location = g.country(s.ip)
location = g.country(ip)
except:
location = None
if location:

View file

@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
from celery.execute import send_task
from django.conf import settings
from app.celery import app
key = 'websocket'
def trigger_event(event, data):
if settings.WEBSOCKET:
send_task('trigger_event', [event, data], exchange=key, routing_key=key)
app.send_task('trigger_event', [event, data], exchange=key, routing_key=key)