From ff09659f327265c73ab0f451a26e597ad429ff0b Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Wed, 19 Oct 2005 20:28:10 +0000 Subject: [PATCH] unused git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@115 839d8a87-29fc-0310-9880-83ba4fa771e5 --- bin/cron/stats/genereParselogCat | 16 --- bin/cron/stats/plot-graphs | 163 ------------------------ bin/devel/tplgettext.php | 18 --- bin/smtp_bounce_proxy.py | 262 --------------------------------------- 4 files changed, 459 deletions(-) delete mode 100755 bin/cron/stats/genereParselogCat delete mode 100755 bin/cron/stats/plot-graphs delete mode 100755 bin/devel/tplgettext.php delete mode 100755 bin/smtp_bounce_proxy.py diff --git a/bin/cron/stats/genereParselogCat b/bin/cron/stats/genereParselogCat deleted file mode 100755 index d57cced..0000000 --- a/bin/cron/stats/genereParselogCat +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -catfiles="" -zcatfiles="" -base=/var/log/mail.log -#base=/var/log/maillog - -for i in `seq 7 -1 0`; do - [ -f $base.$i ] && catfiles="$catfiles $base.$i" - [ -f $base.$i.gz ] && zcatfiles="$zcatfiles $base.$i.gz" -done -[ -f $base ] && catfiles="$catfiles $base" - -# on fait le cat -[ -n "$zcatfiles" ] && zcat $zcatfiles -[ -n "$catfiles" ] && cat $catfiles - diff --git a/bin/cron/stats/plot-graphs b/bin/cron/stats/plot-graphs deleted file mode 100755 index d85e4c4..0000000 --- a/bin/cron/stats/plot-graphs +++ /dev/null @@ -1,163 +0,0 @@ -#!/bin/bash - -SCRIPTSDIR=`dirname $0` -STATSDIR=/home/web/stats - -DATE=$(date "+%d" -d "1 day ago") -DATE2=$(date "+%m%d%y" -d "1 day ago") - -ANNEE=$(date "+%Y") - -#génère les données -#atsar -H -n$DATE | grep access | grep -v https > /tmp/access.dat -atsar -S -P -n$DATE | grep ':' > /tmp/load.dat -atsar -S -u -n$DATE | grep all > /tmp/cpu.dat -atsar -S -d -n$DATE | grep disk00 > /tmp/disk.dat -atsar -S -r -n$DATE | grep M | tr -d "MK" > /tmp/mem.dat -atsar -S -l -n$DATE | grep eth0 > /tmp/eth0.dat -atsar -S -L -n$DATE | grep eth0 > /tmp/eth0err.dat -atsar -S -t -n$DATE | grep -v -i linux | grep '\.' > /tmp/tcp.dat -atsar -S -U -n$DATE | grep -v -i linux | grep '\.' > /tmp/udp.dat -awk '{ if (i!=6) {a+=$2; b+=$3; c+=$4; d+=$5; e+=$6; f+=$7; i++} else { print $1,a,b,c,d,e,f; i=a=b=c=d=e=f=0; } }' $STATSDIR/nbmails > /tmp/nbmails -mysql x4dat --skip-column-names -B -e "SELECT promo,COUNT(*) FROM auth_user_md5 WHERE (promo > 1950) and (perms in ('user','admin')) GROUP BY promo" > /tmp/promo - -mysql x4dat --skip-column-names -B > /tmp/promo2 << EOF -create temporary table countx type = HEAP select promo,count(*) as nb FROM auth_user_md5 WHERE (promo > 1940) and (deces = '0000-00-00') and not(perms='ext') GROUP BY promo; -create temporary table countinscrits type = HEAP select promo,count(*) as nb FROM auth_user_md5 WHERE (promo > 1940) and (deces = '0000-00-00') and (perms in ('admin','user')) GROUP BY promo; -select x.promo, ins.nb*100/x.nb from countx as x, countinscrits as ins where x.promo = ins.promo; -EOF - -#Inscrits (depuis le début) -gnuplot <100)?100:x -set output "$STATSDIR/graph-promo2.png" -set term png small -set title "Pourcentage d'inscrits par promotion (a partir de 1940)" -set size 640/480 -set yr [0:100] -set xr [1940:$ANNEE] -plot "/tmp/promo2" using 1:2 title '' with boxes -EOF -#plot "/tmp/promo2" using 1:(max100(\$2)) title '' with boxes - -rm -f /tmp/cpu.dat /tmp/load.dat /tmp/disk.dat /tmp/mem.dat /tmp/eth0.dat /tmp/eth0err.dat /tmp/tcp.dat /tmp/udp.dat /tmp/nbmails /tmp/promo /tmp/promo2 diff --git a/bin/devel/tplgettext.php b/bin/devel/tplgettext.php deleted file mode 100755 index 27a26e9..0000000 --- a/bin/devel/tplgettext.php +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/php -$file) { - if($i == 0) continue; - $fp = fopen($file,'r'); - $fc = fread($fp,filesize($file)); - fclose($fp); - - preg_match_all('!(""".*?""")!s', $fc, $res); - if(count($res[1])) { - $fp = fopen($file.'.py','w'); - foreach($res[1] as $l) { - fwrite($fp,'_('.stripslashes($l).")\n"); - } - fclose($fp); - } - } -?> diff --git a/bin/smtp_bounce_proxy.py b/bin/smtp_bounce_proxy.py deleted file mode 100755 index 675540c..0000000 --- a/bin/smtp_bounce_proxy.py +++ /dev/null @@ -1,262 +0,0 @@ -#! /usr/bin/python -# set:encoding=iso-8859-1: - -import asyncore -import email -import os, re, sys - -from email import Message, MIMEText, MIMEMultipart -from email.Iterators import typed_subpart_iterator, _structure -from smtpd import PureProxy - -import ConfigParser -import MySQLdb - -IGNORE = 0 -NOTICE = 1 -ERROR = 2 - -FROM_PORT = 20024 -TO_HOST = 'olympe.madism.org' -TO_PORT = 25 - - -################################################################################ -# -# Functions -# -#------------------------------------------------------------------------------- - -config = ConfigParser.ConfigParser() -config.read(os.path.dirname(__file__)+'/../configs/platal.conf') - -def get_config(sec,val,default=None): - try: - return config.get(sec, val)[1:-1] - except ConfigParser.NoOptionError, e: - if default is None: - print e - sys.exit(1) - else: - return default - -def connectDB(): - db = MySQLdb.connect( - db = 'x4dat', - user = get_config('Core', 'dbuser'), - passwd = get_config('Core', 'dbpwd'), - unix_socket='/var/run/mysqld/mysqld.sock') - db.ping() - return db.cursor() - -def msg_of_str(data): return email.message_from_string(data, _class=BounceMessage) - -################################################################################ -# -# Classes -# -#------------------------------------------------------------------------------- - -class BounceMessage(Message.Message): - def body(self): - """this method returns the part that is commonely designed as the 'body' - - for the multipart mails, we go into the first part that have non multipart childs, and then : - we return its first text/plain part if it exsists - else we return the first text/* part if it exists - else we return None else - - for non multipart mails, we just return the current payload - """ - if self.is_multipart(): - _body = self - while _body.get_payload(0).is_multipart(): - _body = _body.get_payload(0) - - buffer = None - for part in typed_subpart_iterator(_body): - if part.get_content_subtype() == 'plain': - return part.get_payload(decode=True) - if buffer is None: - buffer = part - return buffer.get_payload(decode=True) - return self.get_payload(decode=True) - - def _qmail_attached_mail(self): - """qmail is a dumb MTA that put the mail that has bounced RAW into the bounce message, - instead of making a traditionnal message/rfc822 attachement like any other MTA - - it seems to be designed like this : - - ============================================= - [...QMAIL crap...] - --- Below this line is a copy of the message. - - Return-Path: <...> - [rest of the embeded mail] - ============================================= - - so we just cut the qmail crap, and build a new message from the rest. - - may DJB burn into coder's hell - """ - msg = self.get_payload(decode=True) - pos = msg.find("\n--- Below this line is a copy of the message.") - if pos is -1: - return None - pos = msg.find("Return-Path:", pos) - return msg_of_str(msg[pos:]) - - def attached_mail(self): - """returns the attached mail that bounced, if it exists. - we try this : - - is the mail multipart ? - Yes : - (1) return the first message/rfc822 part. - (2) return the first text/rfc822-headers part (AOHell) - (3) return None (may be a vacation + some disclaimer in attachment) - No: - try to return the qmail-style embeded mail (but may be a vacation) - """ - if self.is_multipart(): - for part in typed_subpart_iterator(self, 'message', 'rfc822'): - return part - for part in typed_subpart_iterator(self, 'text', 'rfc822-headers'): - return part - return None - return self._qmail_attached_mail() - - def error_level(self): - """determine the level of an error: - IGNORE == drop the mail - NOTICE == vacation, or any informative message we want to forward as is - ERROR == errors, that we want to handle - """ - - body = self.body() - if not body: - return (IGNORE, '') - - mysql.execute ( "SELECT lvl,re,text FROM emails_bounces_re ORDER BY pos" ) - nb = int(mysql.rowcount) - for x in range(0,nb): - row = mysql.fetchone() - if re.compile(str(row[1]), re.I | re.M).search(body): - return (int(row[0]), str(row[2])) - - return (NOTICE, '') - - def forge_error(self, alias, dest, txt): - """we have to do our little treatments for the broken mail, - and then we create an informative message for the original SENDER to : - - explain to him what happened (the detailed error) - - try to guess if the user may or may not have had the mail (by another leg) - - if no other leg, give an information to the SENDER on how he can give to us a real good leg - and attach any sensible information about the original mail (@see attached_mail) - """ - - mysql.execute("SELECT id FROM aliases WHERE alias='%s' AND type IN ('alias', 'a_vie') LIMIT 1" % (alias)) - if int(mysql.rowcount) is not 1: - return None - uid = mysql.fetchone()[0] - mysql.execute("UPDATE emails SET panne = NOW() WHERE uid='%s' AND email='%s'" % (uid, dest)) - mysql.execute("REPLACE INTO emails_broken (uid,email) VALUES(%s, '%s')" % (uid, dest)) - mysql.execute("""SELECT COUNT(*), - IFNULL(SUM(panne=0 OR (last!=0 AND ( TO_DAYS(NOW())-TO_DAYS(last) )>7 AND panne""" - bounce['To'] = sender - self._deliver("MAILER-DAEMON@bounces.m4x.org", [sender], bounce.as_string()) - except: - pass - # SPAM or broken msg, we just drop it - return None - - -################################################################################ -# -# Main -# -#------------------------------------------------------------------------------- - -mysql = connectDB() -Proxy = BounceProxy(('127.0.0.1', FROM_PORT), (TO_HOST, TO_PORT)) -asyncore.loop() - -- 2.1.4