diff --git a/pandora/archive/management/commands/continue_encoding.py b/pandora/archive/management/commands/continue_encoding.py index d2f0f75bd..61bf2317e 100644 --- a/pandora/archive/management/commands/continue_encoding.py +++ b/pandora/archive/management/commands/continue_encoding.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 -from optparse import make_option from django.core.management.base import BaseCommand diff --git a/pandora/archive/management/commands/extract_derivatives.py b/pandora/archive/management/commands/extract_derivatives.py index 38ec941ea..c859492f5 100644 --- a/pandora/archive/management/commands/extract_derivatives.py +++ b/pandora/archive/management/commands/extract_derivatives.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 -from optparse import make_option from django.core.management.base import BaseCommand @@ -14,12 +13,13 @@ class Command(BaseCommand): """ help = 'extract derivatives, run this to recreate all derivatives. i.e after adding new resolutions' args = '' - option_list = BaseCommand.option_list + ( - make_option('--rebuild', action='store_true', dest='rebuild', + + def add_arguments(self, parser): + parser.add_argument('--rebuild', action='store_true', dest='rebuild', default=False, help='reencode all derivatives again'), - make_option('--forground', action='store_true', dest='forground', + parser.add_argument('--forground', action='store_true', dest='forground', default=False, help='dont dispatch encoding to celery but run in forground'), - ) + def handle(self, **options): for s in models.Stream.objects.filter(source=None): if options['forground']: diff --git a/pandora/item/management/commands/rebuild_filter.py b/pandora/item/management/commands/rebuild_filter.py index b50c1bdca..b3438d305 100644 --- a/pandora/item/management/commands/rebuild_filter.py +++ b/pandora/item/management/commands/rebuild_filter.py @@ -2,7 +2,6 @@ # vi:si:et:sw=4:sts=4:ts=4 from __future__ import print_function -from optparse import make_option from django.core.management.base import BaseCommand from django.db import connection, transaction @@ -17,10 +16,10 @@ import clip.models class Command(BaseCommand): help = 'update filters, run after adding new filters' args = '' - option_list = BaseCommand.option_list + ( - make_option('--debug', action='store_true', dest='debug', + + def add_arguments(self, parser): + parser.add_argument('--debug', action='store_true', dest='debug', default=False, help='print sql commans'), - ) def handle(self, **options): ids = [i['id'] for i in models.Item.objects.all().values('id')] diff --git a/pandora/item/management/commands/rebuild_find.py b/pandora/item/management/commands/rebuild_find.py index 8d03b96e6..0d6e04fc5 100644 --- a/pandora/item/management/commands/rebuild_find.py +++ b/pandora/item/management/commands/rebuild_find.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 from __future__ import print_function -from optparse import make_option from django.core.management.base import BaseCommand from django.db import connection, transaction @@ -16,10 +15,6 @@ import clip.models class Command(BaseCommand): help = 'update find values, run after adding new keys' args = '' - option_list = BaseCommand.option_list + ( - make_option('--debug', action='store_true', dest='debug', - default=False, help='print sql commans'), - ) def handle(self, **options): ids = [i['id'] for i in models.Item.objects.all().values('id')] diff --git a/pandora/item/management/commands/rebuild_indexes.py b/pandora/item/management/commands/rebuild_indexes.py index 8f27e28b5..0ef2bc675 100644 --- a/pandora/item/management/commands/rebuild_indexes.py +++ b/pandora/item/management/commands/rebuild_indexes.py @@ -2,8 +2,6 @@ # vi:si:et:sw=4:sts=4:ts=4 from __future__ import print_function -from optparse import make_option - from django.core.management.base import BaseCommand from django.db import connection, transaction from django.db.models import fields @@ -17,10 +15,10 @@ import clip.models class Command(BaseCommand): help = 'update find, sort, filter indexes' args = '' - option_list = BaseCommand.option_list + ( - make_option('--debug', action='store_true', dest='debug', - default=False, help='print sql commans'), - ) + + def add_arguments(self, parser): + parser.add_argument('--debug', action='store_true', dest='debug', + default=False, help='print sql commans') def handle(self, **options): ids = [i['id'] for i in models.Item.objects.all().values('id')] diff --git a/pandora/item/management/commands/rebuild_sort.py b/pandora/item/management/commands/rebuild_sort.py index b8e89992b..378d061e8 100644 --- a/pandora/item/management/commands/rebuild_sort.py +++ b/pandora/item/management/commands/rebuild_sort.py @@ -2,7 +2,6 @@ # vi:si:et:sw=4:sts=4:ts=4 from __future__ import print_function -from optparse import make_option from django.core.management.base import BaseCommand from django.db import connection, transaction @@ -16,10 +15,10 @@ from ... import models class Command(BaseCommand): help = 'update sort values, run after changing sort keys' args = '' - option_list = BaseCommand.option_list + ( - make_option('--debug', action='store_true', dest='debug', - default=False, help='print sql commans'), - ) + + def add_arguments(self, parser): + parser.add_argument('--debug', action='store_true', dest='debug', + default=False, help='print sql commans') def handle(self, **options): ids = [i['id'] for i in models.Item.objects.all().values('id')] diff --git a/pandora/item/management/commands/sqlfindindex.py b/pandora/item/management/commands/sqlfindindex.py index d9fe3b55c..5c59eec39 100644 --- a/pandora/item/management/commands/sqlfindindex.py +++ b/pandora/item/management/commands/sqlfindindex.py @@ -2,7 +2,6 @@ # vi:si:et:sw=4:sts=4:ts=4 from __future__ import print_function -from optparse import make_option from django.core.management.base import BaseCommand from django.db import connection, transaction @@ -19,10 +18,10 @@ class Command(BaseCommand): """ help = 'sql create statements for find tables to use trigram index' args = '' - option_list = BaseCommand.option_list + ( - make_option('--debug', action='store_true', dest='debug', - default=False, help='print sql commans'), - ) + + def add_arguments(self, parser): + parser.add_argument('--debug', action='store_true', dest='debug', + default=False, help='print sql commans') def handle(self, **options): cursor = connection.cursor() @@ -43,4 +42,4 @@ class Command(BaseCommand): indexes = connection.introspection.get_indexes(cursor, table_name) if name not in indexes: create_index("%s_%s_idx"%(table_name, name), table_name, name) - transaction.commit_unless_managed() + transaction.commit() diff --git a/pandora/item/management/commands/sync_itemsort.py b/pandora/item/management/commands/sync_itemsort.py index 0d176070b..b7656adef 100644 --- a/pandora/item/management/commands/sync_itemsort.py +++ b/pandora/item/management/commands/sync_itemsort.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 from __future__ import print_function -from optparse import make_option from django.core.management.base import BaseCommand from django.db import connection, transaction @@ -19,10 +18,10 @@ class Command(BaseCommand): """ help = 'alter table to match itemKeys in site.json.' args = '' - option_list = BaseCommand.option_list + ( - make_option('--debug', action='store_true', dest='debug', - default=False, help='print sql commans'), - ) + + def add_arguments(self, parser): + parser.add_argument('--debug', action='store_true', dest='debug', + default=False, help='print sql commans') def handle(self, **options): table_name = models.ItemSort._meta.db_table @@ -69,7 +68,7 @@ class Command(BaseCommand): f.null and "DROP" or "SET") changes.append(sql) rebuild = True - + #also update clip index table_name = clip.models.Clip._meta.db_table db_rows = connection.introspection.get_table_description(cursor, table_name) @@ -108,7 +107,7 @@ class Command(BaseCommand): if options['debug']: print(sql) cursor.execute(sql) - transaction.commit_unless_managed() + transaction.commit() if rebuild: print("Updating sort values...") ids = [i['id'] for i in models.Item.objects.all().values('id')] diff --git a/pandora/item/management/commands/update_external.py b/pandora/item/management/commands/update_external.py index da5057d71..2577d5841 100644 --- a/pandora/item/management/commands/update_external.py +++ b/pandora/item/management/commands/update_external.py @@ -2,7 +2,6 @@ # vi:si:et:sw=4:sts=4:ts=4 from __future__ import print_function -from optparse import make_option from django.core.management.base import BaseCommand @@ -16,12 +15,12 @@ class Command(BaseCommand): """ help = 'listen to rabbitmq and execute encoding tasks.' args = '' - option_list = BaseCommand.option_list + ( - make_option('--all', action='store_true', dest='all', + + def add_arguments(self, parser): + parser.add_argument('--all', action='store_true', dest='all', default=False, help='update all items, otherwise oldes N'), - make_option('-n', '--items', action='store', dest='items', type=int, + parser.add_argument('-n', '--items', action='store', dest='items', type=int, default=30, help='number of items ot update'), - ) def handle(self, **options): offset = 0 diff --git a/pandora/websocket/management/commands/websocketd.py b/pandora/websocket/management/commands/websocketd.py index da54458cb..d56fa3ef2 100644 --- a/pandora/websocket/management/commands/websocketd.py +++ b/pandora/websocket/management/commands/websocketd.py @@ -3,7 +3,6 @@ from __future__ import absolute_import import os -from optparse import make_option from django.core.management.base import BaseCommand from django.conf import settings @@ -18,14 +17,13 @@ class Command(BaseCommand): """ help = 'run websocket daemon' args = '' - option_list = BaseCommand.option_list + ( - make_option('--debug', + def add_arguments(self, parser): + parser.add_argument('--debug', action='store_true', dest='debug', default=False, help='enable debug'), - make_option("--pidfile", dest="pidfile",metavar="PIDFILE"), - ) + parser.add_argument("--pidfile", dest="pidfile",metavar="PIDFILE"), def handle(self, **options): socket = daemon.Daemon(settings.WEBSOCKET_PORT, settings.WEBSOCKET_ADDRESS)