check_portrait_permissions.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:aurora 作者: carnby 项目源码 文件源码
def handle(self, *args, **options):
        api_keys = settings.TWITTER_USER_KEYS
        auth = tweepy.OAuthHandler(api_keys['consumer_key'], api_keys['consumer_secret'])
        auth.set_access_token(api_keys['access_token_key'], api_keys['access_token_secret'])

        new_portraits = Portrait.objects.filter(active=True, demo_portrait=False)

        print('scheduled portraits', new_portraits.count())

        for portrait in new_portraits:
            is_new_portrait = portrait.portrait_content is None

            print('user', portrait.auth_screen_name)
            print('new', is_new_portrait)

            try:
                portrait_api(portrait)
                print('OK')
            except TweepError as err:
                print('ERROR', err)
                portrait.active = False
                portrait.save()
                continue
            except Exception as err:
                print('ERROR', err)
                continue

            # to avoid too many connections
            time.sleep(5)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号