65 lines
1.6 KiB
Python
Executable file
65 lines
1.6 KiB
Python
Executable file
#!/usr/bin/python
|
|
#
|
|
# Hack par CC 13/07/1999 pour envoyer sur crans.cvs-checkins un
|
|
# compte-rendu d'activité de ce qui se passe...
|
|
#
|
|
# modif par SamK 22/11/99: splitter les lignes, sinon nntplib refuse le message
|
|
# si ya des lignes trop longues..
|
|
#
|
|
# modif par OS 15/05/00 ajout d'un Reply-To...
|
|
#
|
|
# Intimement lié à CVSROOT/loginfo
|
|
#
|
|
|
|
import nntplib,string,os,StringIO
|
|
|
|
def LFsplit(s):
|
|
res=""
|
|
while len(s)>80 :
|
|
pos=string.find(s,' ',65,80)
|
|
if pos < 0 :
|
|
res=res+s[0:75]+'\n'
|
|
s=s[75:len(s)+1]
|
|
else :
|
|
res=res+s[0:pos]+'\n'
|
|
s=s[pos+1:len(s)+1]
|
|
if len(s)>0:
|
|
res=res+s
|
|
return res
|
|
|
|
for uid in os.listdir('/var/cvs'):
|
|
try:
|
|
so = []
|
|
fi = open('/var/cvs/'+uid,'r')
|
|
|
|
so.append("From: CVS admin <root@crans.ens-cachan.fr>\n" + \
|
|
("Subject: CVS Commit par %s\n" % uid)+ \
|
|
"Organization: Radio ragots\n" + \
|
|
"Newsgroups: crans.cvs-checkins\n" + \
|
|
"Reply-To: Nounous <nounous@crans.ens-cachan.fr>\n" + \
|
|
"Followup-To: crans.informatique\n" )
|
|
|
|
so.append("MIME-Version: 1.0\n" + \
|
|
"Content-Type: text/plain\n")
|
|
so.append("\n")
|
|
envoie = 0
|
|
while 1:
|
|
s = fi.readline()
|
|
if not s: break
|
|
envoie = 1
|
|
s=LFsplit(s)
|
|
so.append(s)
|
|
|
|
|
|
# maintenant, on envoie :
|
|
|
|
if envoie:
|
|
sso = string.join(so,'')
|
|
fso = StringIO.StringIO(sso)
|
|
nntplib.NNTP('news.crans.ens-cachan.fr').post(fso)
|
|
#print sso
|
|
os.unlink('/var/cvs/'+uid)
|
|
except:
|
|
raise
|
|
|
|
|