本文整理汇总了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)
示例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"
示例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
示例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)
示例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)