Beispiel #1
0
def _add_sync_task_and_push_queue(provider, user):

    task_ids = [x.category for x in SyncTask.gets_by_user(user)]

    if provider == config.OPENID_DOUBAN:
        if str(config.CATE_DOUBAN_STATUS) not in task_ids:
            t = SyncTask.add(config.CATE_DOUBAN_STATUS, user.id)
            t and TaskQueue.add(t.id, t.kind)

    elif provider == config.OPENID_SINA:
        if str(config.CATE_SINA_STATUS) not in task_ids:
            t = SyncTask.add(config.CATE_SINA_STATUS, user.id)
            t and TaskQueue.add(t.id, t.kind)
    elif provider == config.OPENID_TWITTER:
        if str(config.CATE_TWITTER_STATUS) not in task_ids:
            t = SyncTask.add(config.CATE_TWITTER_STATUS, user.id)
            t and TaskQueue.add(t.id, t.kind)
    elif provider == config.OPENID_QQ:
        if str(config.CATE_QQWEIBO_STATUS) not in task_ids:
            t = SyncTask.add(config.CATE_QQWEIBO_STATUS, user.id)
            t and TaskQueue.add(t.id, t.kind)
    elif provider == config.OPENID_RENREN:
        for cate in (config.CATE_RENREN_STATUS, config.CATE_RENREN_BLOG,
                     config.CATE_RENREN_ALBUM, config.CATE_RENREN_PHOTO):
            if str(cate) not in task_ids:
                t = SyncTask.add(cate, user.id)
                t and TaskQueue.add(t.id, t.kind)
    elif provider == config.OPENID_INSTAGRAM:
        if str(config.CATE_INSTAGRAM_STATUS) not in task_ids:
            t = SyncTask.add(config.CATE_INSTAGRAM_STATUS, user.id)
            t and TaskQueue.add(t.id, t.kind)
Beispiel #2
0
def _add_sync_task_and_push_queue(provider, user):
        
    task_ids = [x.category for x in SyncTask.gets_by_user(user)]

    if provider == config.OPENID_DOUBAN:
        if str(config.CATE_DOUBAN_STATUS) not in task_ids:
            t = SyncTask.add(config.CATE_DOUBAN_STATUS, user.id)
            t and TaskQueue.add(t.id, t.kind)

    elif provider == config.OPENID_SINA:
        if str(config.CATE_SINA_STATUS) not in task_ids:
            t = SyncTask.add(config.CATE_SINA_STATUS, user.id)
            t and TaskQueue.add(t.id, t.kind)
    elif provider == config.OPENID_TWITTER:
        if str(config.CATE_TWITTER_STATUS) not in task_ids:
            t = SyncTask.add(config.CATE_TWITTER_STATUS, user.id)
            t and TaskQueue.add(t.id, t.kind)
    elif provider == config.OPENID_QQ:
        if str(config.CATE_QQWEIBO_STATUS) not in task_ids:
            t = SyncTask.add(config.CATE_QQWEIBO_STATUS, user.id)
            t and TaskQueue.add(t.id, t.kind)
    elif provider == config.OPENID_RENREN:
        for cate in (config.CATE_RENREN_STATUS, config.CATE_RENREN_BLOG, 
                config.CATE_RENREN_ALBUM, config.CATE_RENREN_PHOTO):
            if str(cate) not in task_ids:
                t = SyncTask.add(cate, user.id)
                t and TaskQueue.add(t.id, t.kind)
    elif provider == config.OPENID_INSTAGRAM:
        if str(config.CATE_INSTAGRAM_STATUS) not in task_ids:
            t = SyncTask.add(config.CATE_INSTAGRAM_STATUS, user.id)
            t and TaskQueue.add(t.id, t.kind)
Beispiel #3
0
def profile():
    u = g.user
    sync_tasks = SyncTask.gets_by_user(u)
    my_sync_cates = [x.category for x in sync_tasks]
    site_homepage_list = []
    for ua in g.user_alias:
        if ua.type == config.OPENID_TYPE_DICT[config.OPENID_DOUBAN]:
            site_homepage_list.append({'site':u'豆瓣', 'homepage':'http://www.douban.com/people/%s' %ua.alias})
        elif ua.type == config.OPENID_TYPE_DICT[config.OPENID_SINA]:
            site_homepage_list.append({'site':u'新浪微博', 'homepage':'http://www.weibo.com/%s' %ua.alias})
        elif ua.type == config.OPENID_TYPE_DICT[config.OPENID_TWITTER]:
            site_homepage_list.append({'site':u'twitter', 'homepage':'http://www.twitter.com/%s' %ua.alias})
    return render_template("profile.html", user=u, 
            my_sync_cates = my_sync_cates, site_homepage_list=site_homepage_list, config=config)
Beispiel #4
0
def _add_sync_task_and_push_queue(provider, user):
        
        task_ids = [x.category for x in SyncTask.gets_by_user(user)]

        if provider == config.OPENID_DOUBAN:
            if str(config.CATE_DOUBAN_MINIBLOG) not in task_ids:
                t = SyncTask.add(config.CATE_DOUBAN_MINIBLOG, user.id)
                t and TaskQueue.add(t.id, t.kind)
            if str(config.CATE_DOUBAN_NOTE) not in task_ids:
                t = SyncTask.add(config.CATE_DOUBAN_NOTE, user.id)
                t and TaskQueue.add(t.id, t.kind)

        elif provider == config.OPENID_SINA:
            if str(config.CATE_SINA_STATUS) not in task_ids:
                t = SyncTask.add(config.CATE_SINA_STATUS, user.id)
                t and TaskQueue.add(t.id, t.kind)
        elif provider == config.OPENID_TWITTER:
            if str(config.CATE_TWITTER_STATUS) not in task_ids:
                t = SyncTask.add(config.CATE_TWITTER_STATUS, user.id)
                t and TaskQueue.add(t.id, t.kind)
Beispiel #5
0
def _add_sync_task_and_push_queue(provider, user):

    task_ids = [x.category for x in SyncTask.gets_by_user(user)]

    if provider == config.OPENID_DOUBAN:
        if str(config.CATE_DOUBAN_STATUS) not in task_ids:
            t = SyncTask.add(config.CATE_DOUBAN_STATUS, user.id)
            t and TaskQueue.add(t.id, t.kind)

    elif provider == config.OPENID_SINA:
        if str(config.CATE_SINA_STATUS) not in task_ids:
            t = SyncTask.add(config.CATE_SINA_STATUS, user.id)
            t and TaskQueue.add(t.id, t.kind)
    elif provider == config.OPENID_TWITTER:
        if str(config.CATE_TWITTER_STATUS) not in task_ids:
            t = SyncTask.add(config.CATE_TWITTER_STATUS, user.id)
            t and TaskQueue.add(t.id, t.kind)
    elif provider == config.OPENID_QQ:
        if str(config.CATE_QQWEIBO_STATUS) not in task_ids:
            t = SyncTask.add(config.CATE_QQWEIBO_STATUS, user.id)
            t and TaskQueue.add(t.id, t.kind)
Beispiel #6
0
def profile():
    u = g.user
    sync_tasks = SyncTask.gets_by_user(u)
    my_sync_cates = [x.category for x in sync_tasks]
    return render_template("profile.html", user=u, my_sync_cates=my_sync_cates, config=config)
Beispiel #7
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())