remove optparse
This commit is contained in:
parent
4219246909
commit
2fe857d4fd
10 changed files with 34 additions and 49 deletions
|
@ -1,6 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from optparse import make_option
|
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from optparse import make_option
|
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
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'
|
help = 'extract derivatives, run this to recreate all derivatives. i.e after adding new resolutions'
|
||||||
args = ''
|
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'),
|
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'),
|
default=False, help='dont dispatch encoding to celery but run in forground'),
|
||||||
)
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
for s in models.Stream.objects.filter(source=None):
|
for s in models.Stream.objects.filter(source=None):
|
||||||
if options['forground']:
|
if options['forground']:
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from optparse import make_option
|
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.db import connection, transaction
|
from django.db import connection, transaction
|
||||||
|
@ -17,10 +16,10 @@ import clip.models
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = 'update filters, run after adding new filters'
|
help = 'update filters, run after adding new filters'
|
||||||
args = ''
|
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'),
|
default=False, help='print sql commans'),
|
||||||
)
|
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
ids = [i['id'] for i in models.Item.objects.all().values('id')]
|
ids = [i['id'] for i in models.Item.objects.all().values('id')]
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from optparse import make_option
|
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.db import connection, transaction
|
from django.db import connection, transaction
|
||||||
|
@ -16,10 +15,6 @@ import clip.models
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = 'update find values, run after adding new keys'
|
help = 'update find values, run after adding new keys'
|
||||||
args = ''
|
args = ''
|
||||||
option_list = BaseCommand.option_list + (
|
|
||||||
make_option('--debug', action='store_true', dest='debug',
|
|
||||||
default=False, help='print sql commans'),
|
|
||||||
)
|
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
ids = [i['id'] for i in models.Item.objects.all().values('id')]
|
ids = [i['id'] for i in models.Item.objects.all().values('id')]
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from optparse import make_option
|
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.db import connection, transaction
|
from django.db import connection, transaction
|
||||||
from django.db.models import fields
|
from django.db.models import fields
|
||||||
|
@ -17,10 +15,10 @@ import clip.models
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = 'update find, sort, filter indexes'
|
help = 'update find, sort, filter indexes'
|
||||||
args = ''
|
args = ''
|
||||||
option_list = BaseCommand.option_list + (
|
|
||||||
make_option('--debug', action='store_true', dest='debug',
|
def add_arguments(self, parser):
|
||||||
default=False, help='print sql commans'),
|
parser.add_argument('--debug', action='store_true', dest='debug',
|
||||||
)
|
default=False, help='print sql commans')
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
ids = [i['id'] for i in models.Item.objects.all().values('id')]
|
ids = [i['id'] for i in models.Item.objects.all().values('id')]
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from optparse import make_option
|
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.db import connection, transaction
|
from django.db import connection, transaction
|
||||||
|
@ -16,10 +15,10 @@ from ... import models
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = 'update sort values, run after changing sort keys'
|
help = 'update sort values, run after changing sort keys'
|
||||||
args = ''
|
args = ''
|
||||||
option_list = BaseCommand.option_list + (
|
|
||||||
make_option('--debug', action='store_true', dest='debug',
|
def add_arguments(self, parser):
|
||||||
default=False, help='print sql commans'),
|
parser.add_argument('--debug', action='store_true', dest='debug',
|
||||||
)
|
default=False, help='print sql commans')
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
ids = [i['id'] for i in models.Item.objects.all().values('id')]
|
ids = [i['id'] for i in models.Item.objects.all().values('id')]
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from optparse import make_option
|
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.db import connection, transaction
|
from django.db import connection, transaction
|
||||||
|
@ -19,10 +18,10 @@ class Command(BaseCommand):
|
||||||
"""
|
"""
|
||||||
help = 'sql create statements for find tables to use trigram index'
|
help = 'sql create statements for find tables to use trigram index'
|
||||||
args = ''
|
args = ''
|
||||||
option_list = BaseCommand.option_list + (
|
|
||||||
make_option('--debug', action='store_true', dest='debug',
|
def add_arguments(self, parser):
|
||||||
default=False, help='print sql commans'),
|
parser.add_argument('--debug', action='store_true', dest='debug',
|
||||||
)
|
default=False, help='print sql commans')
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
@ -43,4 +42,4 @@ class Command(BaseCommand):
|
||||||
indexes = connection.introspection.get_indexes(cursor, table_name)
|
indexes = connection.introspection.get_indexes(cursor, table_name)
|
||||||
if name not in indexes:
|
if name not in indexes:
|
||||||
create_index("%s_%s_idx"%(table_name, name), table_name, name)
|
create_index("%s_%s_idx"%(table_name, name), table_name, name)
|
||||||
transaction.commit_unless_managed()
|
transaction.commit()
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from optparse import make_option
|
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.db import connection, transaction
|
from django.db import connection, transaction
|
||||||
|
@ -19,10 +18,10 @@ class Command(BaseCommand):
|
||||||
"""
|
"""
|
||||||
help = 'alter table to match itemKeys in site.json.'
|
help = 'alter table to match itemKeys in site.json.'
|
||||||
args = ''
|
args = ''
|
||||||
option_list = BaseCommand.option_list + (
|
|
||||||
make_option('--debug', action='store_true', dest='debug',
|
def add_arguments(self, parser):
|
||||||
default=False, help='print sql commans'),
|
parser.add_argument('--debug', action='store_true', dest='debug',
|
||||||
)
|
default=False, help='print sql commans')
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
table_name = models.ItemSort._meta.db_table
|
table_name = models.ItemSort._meta.db_table
|
||||||
|
@ -69,7 +68,7 @@ class Command(BaseCommand):
|
||||||
f.null and "DROP" or "SET")
|
f.null and "DROP" or "SET")
|
||||||
changes.append(sql)
|
changes.append(sql)
|
||||||
rebuild = True
|
rebuild = True
|
||||||
|
|
||||||
#also update clip index
|
#also update clip index
|
||||||
table_name = clip.models.Clip._meta.db_table
|
table_name = clip.models.Clip._meta.db_table
|
||||||
db_rows = connection.introspection.get_table_description(cursor, table_name)
|
db_rows = connection.introspection.get_table_description(cursor, table_name)
|
||||||
|
@ -108,7 +107,7 @@ class Command(BaseCommand):
|
||||||
if options['debug']:
|
if options['debug']:
|
||||||
print(sql)
|
print(sql)
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
transaction.commit_unless_managed()
|
transaction.commit()
|
||||||
if rebuild:
|
if rebuild:
|
||||||
print("Updating sort values...")
|
print("Updating sort values...")
|
||||||
ids = [i['id'] for i in models.Item.objects.all().values('id')]
|
ids = [i['id'] for i in models.Item.objects.all().values('id')]
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from optparse import make_option
|
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
|
@ -16,12 +15,12 @@ class Command(BaseCommand):
|
||||||
"""
|
"""
|
||||||
help = 'listen to rabbitmq and execute encoding tasks.'
|
help = 'listen to rabbitmq and execute encoding tasks.'
|
||||||
args = ''
|
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'),
|
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'),
|
default=30, help='number of items ot update'),
|
||||||
)
|
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
offset = 0
|
offset = 0
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from optparse import make_option
|
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -18,14 +17,13 @@ class Command(BaseCommand):
|
||||||
"""
|
"""
|
||||||
help = 'run websocket daemon'
|
help = 'run websocket daemon'
|
||||||
args = ''
|
args = ''
|
||||||
option_list = BaseCommand.option_list + (
|
def add_arguments(self, parser):
|
||||||
make_option('--debug',
|
parser.add_argument('--debug',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
dest='debug',
|
dest='debug',
|
||||||
default=False,
|
default=False,
|
||||||
help='enable debug'),
|
help='enable debug'),
|
||||||
make_option("--pidfile", dest="pidfile",metavar="PIDFILE"),
|
parser.add_argument("--pidfile", dest="pidfile",metavar="PIDFILE"),
|
||||||
)
|
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
socket = daemon.Daemon(settings.WEBSOCKET_PORT, settings.WEBSOCKET_ADDRESS)
|
socket = daemon.Daemon(settings.WEBSOCKET_PORT, settings.WEBSOCKET_ADDRESS)
|
||||||
|
|
Loading…
Reference in a new issue