コード例 #1
0
ファイル: views.py プロジェクト: jiaweihli/neonews
def groups(request):
	global newsgroup
	try:
		username = request.POST['submitted_username']
		password = request.POST['submitted_password']
		newsgroup = NewsGroup('news.cs.illinois.edu', username, password)
	except(Exception):
		return redirect('/')
	else:
		groups = newsgroup.getGroups()
		db_groups = Group.objects.all()
		for group in groups:
			if not db_groups.filter(name=group[0]):
				g = Group(name=group[0], description = group[1])
				g.save()
		return render_to_response('groups/groups.html', {'group_list' : db_groups})
コード例 #2
0
ファイル: main.py プロジェクト: jiaweihli/neonews
def main():
	username = input('Username?\n')
	password = input('Password?\n')
        
	newsgroup = NewsGroup('news.cs.illinois.edu', username, password)

	newsgroup.welcome()
        
	newsgroup.getGroups()
	
	# test group is 'cs.test'..yet it doesn't let me post to there. I get this error when trying to do so: NeoNews.backports.nntplib.NNTPTemporaryError: 423 No articles in 1869-
	# we need to be careful about how we test this. I made a post in cs.classifieds when it worked, but I don't want to spam newsgroups(especially since I didn't get cs.test posting to work)


	#CHANGE TO 'cs.classifieds' to get it to post to classifieds group. I intentionally set it to a bad group so you and I don't accidentally spam the crap out of the newsgroup
#	newsgroup.setGroup('cs.test')
	newsgroup.setGroup('class.fa10.cs225')
	
#	newsgroup.group.postThread(username,'cs.test','test thread', 'This message was sent in Python!')
#	newsgroup.group.listThreads()

	# 4002 is a single-part message, with references
	# 2000 is a multi-part message
	# use message-id normally, not number
	# number is used here for convenience
	newsgroup.group.setThread(4002)

#	print(newsgroup.group.thread.message.get_payload()[1])
	print(newsgroup.group.thread.message.items())