On Sat, 10 Dec 2016 12:31:33 -0500, DFS wrote: > On 12/10/2016 12:06 PM, Wildman wrote: >> 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 > > > That code runs unchanged on py2.7 on Linux (I just now tested it). > > You just need to put in your own credentials for the newsserver, user > and password (lines 2 and 4).
OK, thanks. That didn't occur to me although it should have. -- <Wildman> GNU/Linux user #557453 The cow died so I don't need your bull! -- https://mail.python.org/mailman/listinfo/python-list