aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--contrib/courier-to-mailman.py96
-rw-r--r--contrib/rotatelogs.py68
2 files changed, 82 insertions, 82 deletions
diff --git a/contrib/courier-to-mailman.py b/contrib/courier-to-mailman.py
index 922401fb..320a6e94 100644
--- a/contrib/courier-to-mailman.py
+++ b/contrib/courier-to-mailman.py
@@ -57,69 +57,69 @@ MailmanOwner = "postmaster@localhost"; # Postmaster and abuse mail recepient.
import sys, os, re, string
def main():
- os.nice(5) # Handle mailing lists at non-interactive priority.
+ os.nice(5) # Handle mailing lists at non-interactive priority.
- os.chdir(MailmanVar + "/lists")
+ os.chdir(MailmanVar + "/lists")
- try:
- local = string.lower(os.environ["LOCAL"])
- except:
- # This might happen if we're not using qmail.
- sys.stderr.write("LOCAL not set in environment?\n")
- sys.exit(112)
+ try:
+ local = string.lower(os.environ["LOCAL"])
+ except:
+ # This might happen if we're not using qmail.
+ sys.stderr.write("LOCAL not set in environment?\n")
+ sys.exit(112)
- names = ("root", "postmaster", "mailer-daemon", "mailman-owner", "owner",
- "abuse")
- for i in names:
- if i == local:
- os.execv("/usr/bin/sendmail",
- ("/usr/bin/sendmail", MailmanOwner))
- sys.exit(0)
+ names = ("root", "postmaster", "mailer-daemon", "mailman-owner", "owner",
+ "abuse")
+ for i in names:
+ if i == local:
+ os.execv("/usr/bin/sendmail",
+ ("/usr/bin/sendmail", MailmanOwner))
+ sys.exit(0)
- type = "post"
- listname = string.lower(local)
- types = (("-admin$", "admin"),
- ("-bounces$", "bounces"),
- ("-bounces\+.*$", "bounces"), # for VERP
- ("-confirm$", "confirm"),
- ("-confirm\+.*$", "confirm"),
- ("-join$", "join"),
- ("-leave$", "leave"),
- ("-owner$", "owner"),
- ("-request$", "request"),
- ("-subscribe$", "subscribe"),
- ("-unsubscribe$", "unsubscribe"))
+ type = "post"
+ listname = string.lower(local)
+ types = (("-admin$", "admin"),
+ ("-bounces$", "bounces"),
+ ("-bounces\+.*$", "bounces"), # for VERP
+ ("-confirm$", "confirm"),
+ ("-confirm\+.*$", "confirm"),
+ ("-join$", "join"),
+ ("-leave$", "leave"),
+ ("-owner$", "owner"),
+ ("-request$", "request"),
+ ("-subscribe$", "subscribe"),
+ ("-unsubscribe$", "unsubscribe"))
- for i in types:
- if re.search(i[0],local):
- type = i[1]
- listname = re.sub(i[0],"",local)
+ for i in types:
+ if re.search(i[0],local):
+ type = i[1]
+ listname = re.sub(i[0],"",local)
- if os.path.exists(listname):
- os.execv(MailmanHome + "/mail/mailman",
- (MailmanHome + "/mail/mailman", type, listname))
- else:
- bounce()
+ if os.path.exists(listname):
+ os.execv(MailmanHome + "/mail/mailman",
+ (MailmanHome + "/mail/mailman", type, listname))
+ else:
+ bounce()
- sys.exit(111)
+ sys.exit(111)
def bounce():
- bounce_message = """\
+ bounce_message = """\
TO ACCESS THE MAILING LIST SYSTEM: Start your web browser on
http://%s/
That web page will help you subscribe or unsubscribe, and will
give you directions on how to post to each mailing list.\n"""
- sys.stderr.write(bounce_message % (os.environ["HOST"]))
- sys.exit(100)
+ sys.stderr.write(bounce_message % (os.environ["HOST"]))
+ sys.exit(100)
try:
- sys.exit(main())
+ sys.exit(main())
except SystemExit, argument:
- sys.exit(argument)
+ sys.exit(argument)
except Exception, argument:
- info = sys.exc_info()
- trace = info[2]
- sys.stderr.write("%s %s\n" % (sys.exc_type, argument))
- sys.stderr.write("LINE %d\n" % (trace.tb_lineno))
- sys.exit(111) # Soft failure, try again later.
+ info = sys.exc_info()
+ trace = info[2]
+ sys.stderr.write("%s %s\n" % (sys.exc_type, argument))
+ sys.stderr.write("LINE %d\n" % (trace.tb_lineno))
+ sys.exit(111) # Soft failure, try again later.
diff --git a/contrib/rotatelogs.py b/contrib/rotatelogs.py
index 0341d811..b28638b1 100644
--- a/contrib/rotatelogs.py
+++ b/contrib/rotatelogs.py
@@ -37,7 +37,7 @@ and the logs are rotated.
# Please direct questions on this to the above address.
#
-showLines = 100 # lines of log messages to display before truncating
+showLines = 100 # lines of log messages to display before truncating
import sys, os, string, time, errno
import paths
@@ -59,45 +59,45 @@ text.append('')
logDate = time.strftime('%Y%m%d-%H%M%S', time.localtime(time.time()))
textSend = 0
for log in ( 'error', 'smtp-failures' ):
- fileName = os.path.join(mm_cfg.LOG_DIR, log)
+ fileName = os.path.join(mm_cfg.LOG_DIR, log)
- # rotate file if it contains any data
- stats = os.stat(fileName)
- if stats[stat.ST_SIZE] < 1: continue
- fileNameNew = '%s.%s' % ( fileName, logDate )
- newLogfiles.append(fileNameNew)
- os.rename(fileName, fileNameNew)
- open(fileName, 'w')
- os.chmod(fileName, stat.S_IMODE(stats[stat.ST_MODE]))
- try: os.chown(fileName, stats[stat.ST_UID], stats[stat.ST_GID])
- except OSError: pass # permission denied, DOH!
+ # rotate file if it contains any data
+ stats = os.stat(fileName)
+ if stats[stat.ST_SIZE] < 1: continue
+ fileNameNew = '%s.%s' % ( fileName, logDate )
+ newLogfiles.append(fileNameNew)
+ os.rename(fileName, fileNameNew)
+ open(fileName, 'w')
+ os.chmod(fileName, stat.S_IMODE(stats[stat.ST_MODE]))
+ try: os.chown(fileName, stats[stat.ST_UID], stats[stat.ST_GID])
+ except OSError: pass # permission denied, DOH!
- textSend = 1
- tmp = '# FILE: %s #' % fileNameNew
- text.append('#' * len(tmp))
- text.append(tmp)
- text.append('#' * len(tmp))
- text.append('')
+ textSend = 1
+ tmp = '# FILE: %s #' % fileNameNew
+ text.append('#' * len(tmp))
+ text.append(tmp)
+ text.append('#' * len(tmp))
+ text.append('')
- linesLeft = showLines # e-mail first linesLeft of log files
- for line in fileinput.input(fileNameNew):
- if linesLeft == 0:
- text.append('[... truncated ...]')
- break
- linesLeft = linesLeft - 1
- line = string.rstrip(line)
- text.append(line)
- text.append('')
+ linesLeft = showLines # e-mail first linesLeft of log files
+ for line in fileinput.input(fileNameNew):
+ if linesLeft == 0:
+ text.append('[... truncated ...]')
+ break
+ linesLeft = linesLeft - 1
+ line = string.rstrip(line)
+ text.append(line)
+ text.append('')
# send message if we've actually found anything
if textSend:
- text = string.join(text, '\n') + '\n'
- siteowner = Utils.get_site_email()
- Utils.SendTextToUser(
- 'Mailman Log Report -- %s' % time.ctime(time.time()),
- text, siteowner, siteowner)
+ text = string.join(text, '\n') + '\n'
+ siteowner = Utils.get_site_email()
+ Utils.SendTextToUser(
+ 'Mailman Log Report -- %s' % time.ctime(time.time()),
+ text, siteowner, siteowner)
# compress any log-files we made
if hasattr(mm_cfg, 'COMPRESS_LOGFILES_WITH') and mm_cfg.COMPRESS_LOGFILES_WITH:
- for file in newLogfiles:
- os.system(mm_cfg.COMPRESS_LOGFILES_WITH % file)
+ for file in newLogfiles:
+ os.system(mm_cfg.COMPRESS_LOGFILES_WITH % file)