diff --git a/ctl b/ctl index b518cddd..28c74e12 100755 --- a/ctl +++ b/ctl @@ -10,6 +10,7 @@ self=`readlink "$0"` if [ -z $self ]; then self="$0" fi + if [ "$action" = "init" ]; then cd "`dirname "$self"`" BASE=`pwd` @@ -47,7 +48,15 @@ if [ "$action" = "init" ]; then fi exit 0 fi + if [ "$action" = "manage" ]; then + cmd="pandora/manage.py" +fi +if [ "$action" = "update" ]; then + cmd="update.py" +fi + +if [ ! -z $cmd ]; then cd "`dirname "$self"`" BASE=`pwd` SUDO="" @@ -56,9 +65,10 @@ if [ "$action" = "manage" ]; then SUDO="sudo -H -u $PANDORA_USER" fi shift - $SUDO $BASE/pandora/manage.py $@ + $SUDO "$BASE/$cmd" $@ exit $? fi + if [ `whoami` != 'root' ]; then echo you have to be root or run $0 with sudo exit 1 diff --git a/pandora/app/utils.py b/pandora/app/utils.py index f272e6c8..ee2e9d08 100644 --- a/pandora/app/utils.py +++ b/pandora/app/utils.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import division, with_statement - import time from .models import Settings diff --git a/pandora/archive/chunk.py b/pandora/archive/chunk.py index 148ba24f..8422051e 100644 --- a/pandora/archive/chunk.py +++ b/pandora/archive/chunk.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import division, with_statement - import os import ox diff --git a/pandora/home/apps.py b/pandora/home/apps.py index 1d6cbbdf..90dc7137 100644 --- a/pandora/home/apps.py +++ b/pandora/home/apps.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.apps import AppConfig diff --git a/pandora/item/data_api.py b/pandora/item/data_api.py index 81d9d72c..0c06015f 100644 --- a/pandora/item/data_api.py +++ b/pandora/item/data_api.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import division, with_statement - import ox from django.conf import settings diff --git a/pandora/oxdjango/api/__init__.py b/pandora/oxdjango/api/__init__.py index 4ecadf1d..72294dc6 100644 --- a/pandora/oxdjango/api/__init__.py +++ b/pandora/oxdjango/api/__init__.py @@ -1,3 +1 @@ -from __future__ import absolute_import - from .actions import actions diff --git a/pandora/oxdjango/api/actions.py b/pandora/oxdjango/api/actions.py index f8a91d3a..70249914 100644 --- a/pandora/oxdjango/api/actions.py +++ b/pandora/oxdjango/api/actions.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import division, absolute_import - import inspect import sys diff --git a/pandora/oxdjango/api/site.py b/pandora/oxdjango/api/site.py index ddd5bc49..cac1e021 100644 --- a/pandora/oxdjango/api/site.py +++ b/pandora/oxdjango/api/site.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - from django.urls import path from . import views diff --git a/pandora/oxdjango/api/views.py b/pandora/oxdjango/api/views.py index 1dfe7428..3a4a2e89 100644 --- a/pandora/oxdjango/api/views.py +++ b/pandora/oxdjango/api/views.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import division, absolute_import - import json from django.shortcuts import render diff --git a/pandora/oxdjango/decorators.py b/pandora/oxdjango/decorators.py index bd6942e5..e631daef 100644 --- a/pandora/oxdjango/decorators.py +++ b/pandora/oxdjango/decorators.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - from functools import wraps from .shortcuts import render_to_json_response diff --git a/pandora/sequence/extract.py b/pandora/sequence/extract.py index 5cbcda50..90db3b33 100644 --- a/pandora/sequence/extract.py +++ b/pandora/sequence/extract.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import division import os from PIL import Image @@ -97,7 +96,9 @@ class DataTimeline(): def get_frame(self, pos): frame = int(pos * self.fps) tile = int(frame * 8 / self.timeline_width) - if self.current_tile != tile: + if len(self.file_names) <= tile: + tile = len(self.file_names) - 1 + if self.current_tile != tile and len(self.file_names): self.timeline_image = Image.open(self.file_names[tile]) self.current_tile = tile x = frame * 8 - tile * self.timeline_width diff --git a/pandora/settings.py b/pandora/settings.py index 6cb4f347..99eda0ba 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -2,7 +2,6 @@ # Django settings for pan.do/ra project defaults, # create local_settings.py to overwrite # check pan.do/ra section below for relevant settings -from __future__ import absolute_import import os from os.path import join, normpath, dirname diff --git a/pandora/websocket/management/commands/websocketd.py b/pandora/websocket/management/commands/websocketd.py index 0eb9ed25..f93bc9d6 100644 --- a/pandora/websocket/management/commands/websocketd.py +++ b/pandora/websocket/management/commands/websocketd.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - import os from django.core.management.base import BaseCommand diff --git a/pandora/websocket/worker.py b/pandora/websocket/worker.py index 72c35e5a..1a0e633d 100644 --- a/pandora/websocket/worker.py +++ b/pandora/websocket/worker.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import +import logging from django.conf import settings @@ -8,6 +8,7 @@ from kombu.mixins import ConsumerMixin from . import daemon, key +logger = logging.getLogger('pandora.websocket') queue = Queue('websocket', Exchange(key, type='direct'), routing_key=key) @@ -22,8 +23,11 @@ class Worker(ConsumerMixin): callbacks=[self.process_task])] def process_task(self, body, message): - if body['task'] == 'trigger_event': - daemon.trigger_event(*body['args']) + try: + if body['task'] == 'trigger_event': + daemon.trigger_event(*body['args']) + except: + logger.error('faild to trigger event %s', body, exc_info=True) message.ack() def run(): diff --git a/scripts/poster.0xdb.py b/scripts/poster.0xdb.py index bd05982d..9b9f2470 100755 --- a/scripts/poster.0xdb.py +++ b/scripts/poster.0xdb.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from __future__ import division import os from PIL import Image diff --git a/scripts/poster.indiancinema.py b/scripts/poster.indiancinema.py index 194700d5..bc37fca5 100755 --- a/scripts/poster.indiancinema.py +++ b/scripts/poster.indiancinema.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from __future__ import division import os from PIL import Image diff --git a/scripts/poster.padma.py b/scripts/poster.padma.py index 81ec3dfe..015aaa9b 100755 --- a/scripts/poster.padma.py +++ b/scripts/poster.padma.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from __future__ import division import os from PIL import Image diff --git a/scripts/poster.pandora.py b/scripts/poster.pandora.py index 6177efd8..5f196562 100755 --- a/scripts/poster.pandora.py +++ b/scripts/poster.pandora.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from __future__ import division import os from PIL import Image diff --git a/update.py b/update.py index 566d23f9..3a2c7a40 100755 --- a/update.py +++ b/update.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -from __future__ import print_function import json import os import shutil