from __future__ import print_function

This commit is contained in:
j 2016-02-18 16:19:26 +05:30
commit 6b1ce30eb2
22 changed files with 109 additions and 81 deletions

View file

@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from __future__ import print_function
from django.core.management.base import BaseCommand
from django.conf import settings
from django.db import transaction
@ -19,4 +21,4 @@ class Command(BaseCommand):
i = models.Item.objects.get(public_id=id)
path = i.frame(position, height)
if path:
print path
print(path)

View file

@ -1,5 +1,7 @@
# -*- 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
@ -26,7 +28,7 @@ class Command(BaseCommand):
try:
i = models.Item.objects.get(pk=id)
if options['debug']:
print i
print(i)
i.update_facets()
except:
pass

View file

@ -1,5 +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
@ -25,7 +26,7 @@ class Command(BaseCommand):
for id in ids:
try:
i = models.Item.objects.get(pk=id)
print i
print(i)
i.update_find()
except:
pass

View file

@ -1,5 +1,7 @@
# -*- 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
@ -26,7 +28,7 @@ class Command(BaseCommand):
try:
i = models.Item.objects.get(pk=id)
if options['debug']:
print i
print(i)
i.update_facets()
i.update_sort()
i.update_find()

View file

@ -1,5 +1,7 @@
# -*- 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
@ -25,7 +27,7 @@ class Command(BaseCommand):
try:
i = models.Item.objects.get(pk=id)
if options['debug']:
print i
print(i)
i.update_sort()
except:
pass

View file

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from __future__ import print_function
import os
from glob import glob
@ -25,6 +26,6 @@ class Command(BaseCommand):
for i in models.Item.objects.all().order_by('id')[offset:offset+chunk]:
if not os.path.exists(os.path.join(i.timeline_prefix, 'cuts.json')) or \
not glob('%s/timelinekeyframes16p0.jpg'%i.timeline_prefix):
print i.public_id
print(i.public_id)
tasks.rebuild_timeline.delay(i.public_id)
offset += chunk

View file

@ -1,5 +1,7 @@
# -*- 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
@ -27,7 +29,7 @@ class Command(BaseCommand):
def create_index(index, table, key):
sql = 'CREATE INDEX "%s" ON "%s" USING gin ("%s" gin_trgm_ops)' % (index, table, key)
if options['debug']:
print sql
print(sql)
cursor.execute(sql)
if settings.DB_GIN_TRGM:

View file

@ -1,5 +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
@ -102,17 +103,17 @@ class Command(BaseCommand):
sql = 'BEGIN'
changes.append(sql)
if changes:
print "Updating database schema..."
print("Updating database schema...")
for sql in changes:
if options['debug']:
print sql
print(sql)
cursor.execute(sql)
transaction.commit_unless_managed()
if rebuild:
print "Updating sort values..."
print("Updating sort values...")
ids = [i['id'] for i in models.Item.objects.all().values('id')]
for id in ids:
i = models.Item.objects.get(pk=id)
if options['debug']:
print i
print(i)
i.update_sort()

View file

@ -1,5 +1,7 @@
# -*- 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
@ -27,9 +29,9 @@ class Command(BaseCommand):
qs = models.Item.objects.exclude(public_id__startswith='0x')
count = pos = qs.count()
while (options['all'] and offset <= count) or offset < options['items']:
print offset, pos, count
print(offset, pos, count)
for i in qs.order_by('modified')[:chunk]:
print pos, i.public_id, i.modified
print(pos, i.public_id, i.modified)
i.update_external()
pos -= 1
offset += chunk

View file

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from __future__ import division, with_statement
from __future__ import division, with_statement, print_function
import math
import os
@ -57,7 +56,7 @@ def join_tiles(source_paths, target_path):
target_path, mode, large_tile_h, large_tile_i
)
data['target_images']['large'].save(image_file)
#print image_file
#print(image_file)
if mode != 'keyframes':
# open small tile
small_tile_i = int(large_tile_i / 60)
@ -82,7 +81,7 @@ def join_tiles(source_paths, target_path):
target_path, small_mode, small_tile_h, small_tile_i
)
data['target_images']['small'].save(image_file)
#print image_file
#print(image_file)
if mode == full_tile_mode:
# render full tile
resized = data['target_images']['large'].resize((
@ -171,12 +170,12 @@ def join_tiles(source_paths, target_path):
# save full timelines
image_file = '%stimeline%s%dp.jpg' % (target_path, full_tile_mode, large_tile_h)
data['target_images']['full'].save(image_file)
#print image_file
#print(image_file)
image_file = '%stimeline%s%dp.jpg' % (target_path, full_tile_mode, small_tile_h)
data['target_images']['full'].resize(
(full_tile_w, small_tile_h), Image.ANTIALIAS
).save(image_file)
#print image_file
#print(image_file)
# join cuts
cuts = []
@ -187,7 +186,7 @@ def join_tiles(source_paths, target_path):
with open(p, 'r') as f:
path_cuts = json.load(f)
else:
print p, 'missing'
print(p, 'missing')
path_cuts = []
if i > 0:
cuts.append(offset)
@ -207,7 +206,7 @@ def split_tiles(path, paths, durations):
tiles = {}
for file_name in file_names:
mode = re.split('\d+', file_name[8:])[0]
print file_name, mode
print(file_name, mode)
split = re.split('[a-z]+', file_name[8 + len(mode):-4])
height, index = map(lambda x: int(x) if len(x) else -1, split)
if not mode in tiles:
@ -216,7 +215,7 @@ def split_tiles(path, paths, durations):
tiles[mode][height] = 0
if index + 1 > tiles[mode][height]:
tiles[mode][height] = index + 1
print tiles
print(tiles)
# for each mode
for mode in tiles:
@ -264,5 +263,5 @@ def split_tiles(path, paths, durations):
paths[target_data[i]['item']], mode, height, target_data[i]['tile']
)
# target_image.save(file_name)
print file_name, target_image.size
print(file_name, target_image.size)

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from __future__ import division
from __future__ import division, print_function
import os.path
import mimetypes
import random
@ -168,7 +168,7 @@ def find(request, data):
see: add, edit, get, lookup, remove, upload
'''
if settings.JSON_DEBUG:
print json.dumps(data, indent=2)
print(json.dumps(data, indent=2))
query = parse_query(data, request.user)
response = json_response({})