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


Python Actions.make_post_url方法代码示例

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


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

示例1: make_post

# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import make_post_url [as 别名]
def make_post(sub, post, comment):
    try:
        #make post and comment
        post = Actions.make_post_url(sub, post.title, post.url)
        Actions.make_comment(post, comment)
    except Exception, e:
        print str(e)
开发者ID:arghdos,项目名称:CentralScrutinzer-bot,代码行数:9,代码来源:DataMiner.py

示例2: test_strike_counter

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

    mypraw = u.create_multiprocess_praw(credentials)
    pol = Policies.DebugPolicy(None)
    sub = u.get_subreddit(credentials, mypraw)

    cs = CentralScrutinizer.CentralScrutinizer(credentials, pol, "test_database.db")
    scount = cs.scount

    print "Simple strike count test:"
    #make post
    post = a.make_post_url(sub, "test", "https://www.youtube.com/watch?v=vmT0lCfybR4")

    with DataBase.DataBaseWrapper("test_database.db") as db:
        db.add_reddit([(post.name, "arghdos", "youtube", datetime.datetime.today())])
        db.add_channels([("arghdos", "youtube", "http://www.youtube.com/user/arghdos", Blacklist.BlacklistEnums.NotFound, 2)])

    post.set_flair("test")

    #delete
    post.delete()

    #run counter
    scount.scan()

    #check strikes
    with DataBase.DataBaseWrapper("test_database.db") as db:
        result = db.get_channels(id_filter="arghdos", return_strikes=True)[0][-1]

    if result != 3:
        print "Failed"
        return False

    with DataBase.DataBaseWrapper("test_database.db") as db:
        result = db.get_blacklist([("arghdos", "youtube")])[0] == Blacklist.BlacklistEnums.Blacklisted
    if not result:
        print "Failed"
        return False

    #set to non-blacklisted and run again to check deletion
    db.set_blacklist([("arghdos", "youtube")], Blacklist.BlacklistEnums.NotFound)

     #run counter
    scount.scan()

    #check strikes
    with DataBase.DataBaseWrapper("test_database.db") as db:
        result = db.get_channels(id_filter="arghdos", return_strikes=True)[0][-1]

    if result != 3:
        print "Failed"
        return False

    print "Passed"
开发者ID:arghdos,项目名称:CentralScrutinzer-bot,代码行数:61,代码来源:TestSuite.py

示例3: test_scan_sub

# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import make_post_url [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

示例4: debug_url

# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import make_post_url [as 别名]
 def debug_url(self, message, url=u''):
     logging.debug(message + u"\t" + url)
     if __debug__:
         if url.startswith(u"t3_"):
             url = u"http://redd.it/{}".format(url[3:])
         Actions.make_post_url(self.altsub, message, url)
开发者ID:arghdos,项目名称:CentralScrutinzer-bot,代码行数:8,代码来源:Policies.py

示例5: info_url

# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import make_post_url [as 别名]
 def info_url(self, message, url=u""):
     logging.info(message)
     if __debug__:
         if url.startswith(u"t3_"):
             url = u"http://redd.it/{}".format(url[3:])
         Actions.make_post_url(self.altsub, message, url)
开发者ID:arghdos,项目名称:CentralScrutinzer-bot,代码行数:8,代码来源:Policies.py


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