当前位置: 首页>>代码示例>>Python>>正文


Python Actions.get_posts方法代码示例

本文整理汇总了Python中Actions.get_posts方法的典型用法代码示例。如果您正苦于以下问题:Python Actions.get_posts方法的具体用法?Python Actions.get_posts怎么用?Python Actions.get_posts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Actions的用法示例。


在下文中一共展示了Actions.get_posts方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testGetPosts

# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import get_posts [as 别名]
def testGetPosts(sub):
    # spawn an action
    print "Get Posts:"
    posts = a.get_posts(sub)
    print "Passed" if posts else "Failed"
    return posts != None
开发者ID:arghdos,项目名称:CentralScrutinzer-bot,代码行数:8,代码来源:TestSuite.py

示例2: test_scan_sub

# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import get_posts [as 别名]
def test_scan_sub():
    try:
        os.remove("test_database.db")
    except:
        pass
    credentials = CRImport("TestCredentials.cred")
    credentials["SUBREDDIT"] = "centralscrutinizer"

    # clear old subs
    u.clear_sub(credentials, "thewhitezone")
    u.clear_sub(credentials, "centralscrutinizer")

    #get subs
    mypraw = u.create_multiprocess_praw(credentials)
    wz = u.get_subreddit(credentials, mypraw, "thewhitezone")
    cz = u.get_subreddit(credentials, mypraw, "centralscrutinizer")
    pol = Policies.DebugPolicy(wz)

    print "Starting ScanSub tests..."
    print "Simple blacklist identification:"
    #h'ok here we go.
    #first we'll create three posts from a black/whitelisted channel and a not found
    with DataBase.DataBaseWrapper("test_database.db") as db:
        entries = [
            ("arghdos", "youtube.com", "http://www.youtube.com/user/arghdos", Blacklist.BlacklistEnums.Whitelisted, 0),
            ("IGN", "youtube.com", "http://www.youtube.com/user/IGN", Blacklist.BlacklistEnums.Blacklisted, 0),
            ("Karen Jones", "youtube.com", "http://www.youtube.com/user/Karen Jones", Blacklist.BlacklistEnums.NotFound,
             0)]
        db.add_channels(entries)

        #create scrutinizer
        cs = CentralScrutinizer.CentralScrutinizer(credentials, pol, "test_database.db")
        ss = cs.ss

        #now make posts
        urls = ["https://www.youtube.com/watch?v=-vihDAj5VkY", "https://m.youtube.com/watch?v=G4ApQrbhQp8",
                "http://youtu.be/Cg9PWSHL4Vg"]
        ids = []
        for i in range(len(urls)):
            ids.append(a.make_post_url(cz, url=urls[i], title=str(i)).id)

        #ok, now scan
        ss.scan(3)

        #next check for a 0//whitelist, 1//blacklist
        posts = a.get_posts(wz, 3)
        one = posts.next()
        two = posts.next()

        if (one.title == "0//whitelist") and (two.title == "1//blacklist"):
            print "Passed"
        else:
            print "Failed"
            return False

        print "Reddit record:"
        results = db.get_reddit(date_added=(datetime.datetime.now() - datetime.timedelta(days=1)))
        if len([p for p in results if p[0] in ids]) == 2:
            print "Passed"
        else:
            print "Failed"
            return False

        result = db.newest_reddit_entries(1)
        ss.last_seen = result.next()[0]
        print "Found old:"
        result = ss.scan(3)
        if result == ScanSub.scan_result.FoundOld:
            print "Passed"
        else:
            print "Failed"
            return False
开发者ID:arghdos,项目名称:CentralScrutinzer-bot,代码行数:74,代码来源:TestSuite.py

示例3: get_posts

# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import get_posts [as 别名]
 def get_posts(self, lim):
     return Actions.get_posts(self.sub, lim)
开发者ID:arghdos,项目名称:CentralScrutinzer-bot,代码行数:4,代码来源:ScanSub.py

示例4: testGetComments

# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import get_posts [as 别名]
def testGetComments(sub):
    print "Get Comments:"
    post = a.get_posts(sub, 1)
    comments = a.get_comments(post.next())
    print "Passed" if comments != None and len(comments) and comments[0].body == "test comment" else "Failed"
    return comments != None
开发者ID:arghdos,项目名称:CentralScrutinzer-bot,代码行数:8,代码来源:TestSuite.py

示例5: str

# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import get_posts [as 别名]
                    if str(e).startswith("No JSON object"):
                        logging.error("Reddit-Analytics is down, retrying historical scan after pause...")
                    else:
                        logging.error(str(e))
                        if __debug__:
                            logging.exception(e)
                    #temporary fix to avoid endless waiting while RA is down
                    return []
                except Exception, e:
                    logging.error(str(e))
                    if __debug__:
                        logging.exception(e)
                    #temporary fix to avoid endless waiting while RA is down
                    return []
        else:
            posts = Actions.get_posts(self.sub, 900)
            if posts is None:
                return None

        return posts

    def historical_scan(self, goto):
        posts = self.get_historial_posts(goto)
        if posts is not None and len(posts):
            post_data = [(post.created_utc, post.name, post.url, Actions.get_username(post), post) for post in posts if not post.is_self]
            self.__process_post_list(post_data)
            return scan_result.FoundOld
        return scan_result.Error

    def get_posts(self, lim):
        return Actions.get_posts(self.sub, lim)
开发者ID:arghdos,项目名称:CentralScrutinzer-bot,代码行数:33,代码来源:ScanSub.py


注:本文中的Actions.get_posts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。