mailWarn_dirtyDarcsRepo n'est plus vraiment utile.
This commit is contained in:
parent
66019b9d19
commit
10421ec7d5
3 changed files with 0 additions and 117 deletions
|
@ -18,7 +18,6 @@
|
|||
<Path name="/etc/crans/darcs_defaults"/>
|
||||
|
||||
<!-- mail de notification de fichiers non synchronises -->
|
||||
<Path name="/etc/cron.daily/mailWarn_dirtyDarcsRepo"/>
|
||||
<Python name="/etc/cron.daily/git_dirty_repo"/>
|
||||
<Python name="/etc/cron.weekly/git_dirty_repo"/>
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
<FileInfo>
|
||||
<Info owner='root' group='root' perms='0755'/>
|
||||
</FileInfo>
|
|
@ -1,113 +0,0 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
#
|
||||
# mailWarn_dirtyDarcsRepo : envoie un email de notification si les dépôts
|
||||
# darcs enregistrés sur le serveur contiennent des fichiers qui ne sont
|
||||
# pas à jour.
|
||||
#
|
||||
# Copyright (C) 2007 Nicolas Dandrimont <Nicolas.Dandrimont@crans.org>
|
||||
# Basé sur mailWarn_dirtyEtc écrit par Fred et Jérémie Dimino
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; version 2 dated June,
|
||||
# 1991.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
|
||||
|
||||
import smtplib, os, time, sys, subprocess
|
||||
from socket import gethostname
|
||||
|
||||
os.umask(0002)
|
||||
|
||||
hostname = gethostname().split(".")[0]
|
||||
|
||||
##### CONFIG
|
||||
|
||||
checks = [ '/etc' ]
|
||||
hostspecificchecks = {
|
||||
# Passé sous git
|
||||
# 'bcfg2' : [ '/var/lib/bcfg2' ] ,
|
||||
# 'vert' : [ '/usr/scripts' ] ,
|
||||
'zamok' : [ '/var/www' ] ,
|
||||
}
|
||||
checks += hostspecificchecks.get(hostname,[])
|
||||
|
||||
# Paramètres du mail
|
||||
params = { 'from_name' : '%s Darcs' % hostname.capitalize() ,
|
||||
'from_addr' : 'roots@crans.org' ,
|
||||
'to' : 'roots@crans.org' ,
|
||||
'subject' : 'Darcs Whatsnew sur %s' % hostname.capitalize() }
|
||||
|
||||
##### FIN CONFIG
|
||||
|
||||
def send_mail(mailhost='localhost', mailport=25):
|
||||
|
||||
barre = '='*25 + '\n'
|
||||
|
||||
# Récupération des dossiers dans lesquels Darcs est effectivement installé
|
||||
dirs = []
|
||||
for dir in checks:
|
||||
if os.access(dir + "/_darcs", os.F_OK):
|
||||
dirs.append(dir)
|
||||
|
||||
if dirs == []:
|
||||
return
|
||||
|
||||
# Valeurs initiales
|
||||
resume = ''
|
||||
details = ''
|
||||
|
||||
for dir in dirs:
|
||||
# Récupération de l'état des fichiers
|
||||
darcs = subprocess.Popen(["darcs","whatsnew","-s"], cwd = dir,
|
||||
stdout = subprocess.PIPE)
|
||||
|
||||
if darcs.wait() == 1:
|
||||
# À l'ouest, rien de nouveau
|
||||
continue
|
||||
|
||||
lines = darcs.stdout.read()
|
||||
|
||||
resume += barre
|
||||
resume += 'Fichiers non a jour sur le depot %s de %s\n' % (dir,
|
||||
hostname)
|
||||
resume += barre
|
||||
resume += lines
|
||||
resume += '\n'
|
||||
|
||||
if not resume:
|
||||
# Pas de fichiers non à jour
|
||||
return
|
||||
|
||||
# Préparation du mail
|
||||
params['date'] = time.strftime('%a, %d %b %Y %H:%M:%S +0000',
|
||||
time.gmtime(time.time()))
|
||||
|
||||
mail = 'From: %(from_name)s <%(from_addr)s>\n\
|
||||
To: %(to)s\n\
|
||||
Subject: %(subject)s\n\
|
||||
X-CVSinfo: CRANS\n\
|
||||
X-DarcsInfo: CRANS\n\
|
||||
Date: %(date)s\n\
|
||||
X-Mailer: Python Darcs Check\n\n' % params
|
||||
mail += resume
|
||||
mail += '\n'
|
||||
|
||||
# Envoi du mail
|
||||
conn = smtplib.SMTP()
|
||||
conn.connect(mailhost, mailport)
|
||||
conn.sendmail(params['from_addr'], params['to'], mail)
|
||||
conn.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
send_mail()
|
Loading…
Add table
Add a link
Reference in a new issue