CLP stats: last 500 posts

Wildman best_lay at yahoo.com
Sat Dec 10 12:06:50 EST 2016


On Fri, 09 Dec 2016 16:07:16 -0500, DFS wrote:

> code (py2.7)
> --------------------------------------------------------------
> import sys as y,nntplib as t,datetime as d
> s='<news server>'
> g=y.argv[1]
> n=t.NNTP(s,119,'<usr>','<pw>')
> r,a,b,e,gn=n.group(g)
> def printStat(st,hd,rg):
> 	r,d=n.xhdr(st,'%s-%s'%rg)
> 	p=[]
> 	for i in range(len(d)):
> 		v=d[i][1]
> 		if st=='Subject':v=v[4:] if v[:3]=='Re:' else v
> 		p.append(v)
> 	x=[(i,p.count(i)) for i in set(p)]
> 	x.sort(key=lambda s:(-s[1],s[0].lower()))
> 	print('Posts  %s %s'%(len(set(p)),hd))
> 	for v in x: print(' %s     %s'%(v[1],v[0]))
> 	print
> print 'As of '+d.datetime.now().strftime("%I:%M%p %B %d, %Y") + '\n'
> m=(int(e)-int(y.argv[3])+1,int(e))
> printStat("From","Posters",m)
> printStat("Subject","Subjects",m)
> printStat("User-Agent","User-Agents",m)
> n.quit()
> --------------------------------------------------------------
> 
> usage on Windows:
> $ python stats.py group last N
> $ python stats.py comp.lang.python last 500

Do you happen to have a translation of the code that will
run on Linux?

$ ./nntp.py comp.lang.python last 500
Traceback (most recent call last):
  File "./nntp.py", line 7, in <module>
    n=t.NNTP(s,119,'<usr>','<pw>')
  File "/usr/lib/python2.7/nntplib.py", line 119, in __init__
    self.sock = socket.create_connection((host, port))
  File "/usr/lib/python2.7/socket.py", line 553, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known

-- 
<Wildman> GNU/Linux user #557453
The cow died so I don't need your bull!



More information about the Python-list mailing list