コード例 #1
0
def remove_post(uowm: SqlAlchemyUnitOfWorkManager, post):
    with uowm.start() as uow:
        image_post = uow.image_post.get_by_post_id(post.post_id)
        image_post_current = uow.image_post_current.get_by_post_id(
            post.post_id)
        investigate_post = uow.investigate_post.get_by_post_id(post.post_id)
        link_repost = uow.link_repost.get_by_repost_of(post.post_id)
        image_reposts = uow.image_repost.get_by_repost_of(post.post_id)
        comments = uow.bot_comment.get_by_post_id(post.post_id)
        summons = uow.summons.get_by_post_id(post.post_id)
        image_search = uow.image_search.get_by_post_id(post.post_id)
        user_reports = uow.user_report.get_by_post_id(post.post_id)

        #uow.posts.remove(post)
        if image_post:
            log.debug('Deleting image post %s', image_post.id)
            uow.image_post.remove(image_post)
        if image_post_current:
            log.debug('Deleting image post current %s', image_post_current.id)
            uow.image_post_current.remove(image_post_current)
        if investigate_post:
            log.debug('Deleting investigate %s', investigate_post.id)
            uow.investigate_post.remove(investigate_post)
        if link_repost:
            for r in link_repost:
                log.debug('Deleting link repost %s', r.id)
                uow.link_repost.remove(r)
        if image_reposts:
            for r in image_reposts:
                log.debug('Deleting image repost %s', r.id)
                uow.image_repost.remove(r)
        if comments:
            for c in comments:
                log.debug('Deleting comment %s', c.id)
                uow.bot_comment.remove(c)
        if summons:
            for s in summons:
                log.debug('deleting summons %s', s.id)
                uow.summons.remove(s)
        if image_search:
            for i in image_search:
                log.debug('Deleting image search %s', i.id)
                uow.image_search.remove(i)
        if user_reports:
            for u in user_reports:
                log.debug('Deleting report %s', u.id)
                uow.user_report.remove(u)

        uow.commit()
コード例 #2
0
                                      uowm,
                                      event_logger,
                                      source='submonitor',
                                      live_response=config.live_responses),
                      event_logger=event_logger,
                      config=config)
 redis = get_redis_client(config)
 while True:
     while True:
         queued_items = redis.lrange('submonitor', 0, 20000)
         if len(queued_items) == 0:
             log.info('Sub monitor queue empty.  Starting over')
             break
         log.info('Sub monitor queue still has %s tasks', len(queued_items))
         time.sleep(60)
     with uowm.start() as uow:
         monitored_subs = uow.monitored_sub.get_all()
         for monitored_sub in monitored_subs:
             if not monitored_sub.active:
                 continue
             log.info('Checking sub %s', monitored_sub.name)
             if not monitored_sub.active:
                 log.debug('Sub %s is disabled', monitored_sub.name)
                 continue
             if not monitored_sub.check_all_submissions:
                 log.info('Sub %s does not have post checking enabled',
                          monitored_sub.name)
                 continue
             try:
                 process_monitored_sub.apply_async((monitored_sub, ),
                                                   queue='submonitor')