예제 #1
0
        print '%s queue length: %s' %(datetime.datetime.now(),len(queue_ids)) 
        for qid in queue_ids:
            queue = TaskQueue.get(qid)
            if queue and queue.task_kind == config.K_SYNCTASK:
                print 'syncing task id:', queue.task_id
                sync_task = SyncTask.get(queue.task_id)
                if not sync_task:
                    continue

                ## 现在不同步豆瓣日记
                if str(sync_task.category) == str(config.CATE_DOUBAN_NOTE):
                    continue

                ## 同步wordpress rss
                if str(sync_task.category) == str(config.CATE_WORDPRESS_POST):
                    jobs.sync_wordpress(sync_task)
                    queue.remove()
                    continue

                max_sync_times = 0
                min_id = Status.get_min_origin_id(sync_task.category, sync_task.user_id)
                if sync_task:
                    while True:
                        if max_sync_times >= 6:
                            break
                        r = jobs.sync(sync_task, old=True)
                        new_min_id = Status.get_min_origin_id(sync_task.category, sync_task.user_id)
                        if r == 0 or new_min_id == min_id:
                            break
                        min_id = new_min_id
                        max_sync_times += 1
예제 #2
0
        print '%s queue length: %s' % (datetime.datetime.now(), len(queue_ids))
        for qid in queue_ids:
            queue = TaskQueue.get(qid)
            if queue and queue.task_kind == config.K_SYNCTASK:
                print 'syncing task id:', queue.task_id
                sync_task = SyncTask.get(queue.task_id)
                if not sync_task:
                    continue

                ## 现在不同步豆瓣日记
                if str(sync_task.category) == str(config.CATE_DOUBAN_NOTE):
                    continue

                ## 同步wordpress rss
                if str(sync_task.category) == str(config.CATE_WORDPRESS_POST):
                    jobs.sync_wordpress(sync_task)
                    queue.remove()
                    continue

                max_sync_times = 0
                min_id = Status.get_min_origin_id(sync_task.category,
                                                  sync_task.user_id)
                if sync_task:
                    while True:
                        if max_sync_times >= 6:
                            break
                        r = jobs.sync(sync_task, old=True)
                        new_min_id = Status.get_min_origin_id(
                            sync_task.category, sync_task.user_id)
                        if r == 0 or new_min_id == min_id:
                            break
예제 #3
0
import datetime
from past import config
from past.model.status import SyncTask
from past.model.user import User
import jobs

if __name__ == '__main__':
    user = User.get(sys.argv[1])
    old = sys.argv[2] == "old"

    if not user:
        print "no such user"
        exit(1)

    ts = SyncTask.gets_by_user(user)
    if not ts:
        print "no sync tasks"

    for t in ts:
        try:
            if t.category == config.CATE_WORDPRESS_POST:
                jobs.sync_wordpress(t)
            else:
                jobs.sync(t, old=old)
        except Exception, e:
            import traceback
            print "%s %s" % (datetime.datetime.now(), traceback.format_exc())