[schema][manual] Add South migration for flags on UserMessage

(imported from commit bdf6cf2d5427709e52ef051e3c4a19c5fbb4851c)
This commit is contained in:
Leo Franchi
2013-03-12 12:51:35 -04:00
parent 65d2f65bbb
commit 2c4c6ba43e
3 changed files with 422 additions and 0 deletions

21
zephyr/lib/utils.py Normal file
View File

@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
from time import sleep
# Runs the callback with slices of all_list of a given batch_size
def run_in_batches(all_list, batch_size, callback, sleep_time = 0, logger = None):
if len(all_list) == 0:
return
limit = (len(all_list) / batch_size) + 1;
for i in xrange(limit):
start = i*batch_size
end = (i+1) * batch_size
if end >= len(all_list):
end = len(all_list)
batch = all_list[start:end]
if logger:
logger("Executing %s in batch %s of %s" % (end-start, i+1, limit))
callback(batch)
sleep(sleep_time)