remove optparse

This commit is contained in:
j 2016-02-19 18:19:01 +00:00
parent 4219246909
commit 2fe857d4fd
10 changed files with 34 additions and 49 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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