#!/usr/local/bin/python
# This script is being deprecated, in favor hookups for an external archiver.
# We don't need to lock in this script, because we're never going to change data.
import sys
sys.path.append('/home/mailman/mailman/modules')
import os, types, posix, string
import mm_utils, maillist, htmlformat
try:
sys.stderr = mm_utils.StampedLogger("error", label = 'archives',
manual_reprime=1, nofail=0)
except IOError:
pass # Oh well - SOL on redirect, errors show thru.
print "Content-type: text/html"
print
path = os.environ['PATH_INFO']
list_info = mm_utils.GetPathPieces(path)
if len(list_info) < 1:
print "
Invalid options to CGI script.
"
sys.exit(0)
list_name = string.lower(list_info[0])
try:
list = maillist.MailList(list_name)
except:
print "%s: No such list.
" % list_name
sys.exit(0)
if not list._ready:
print "%s: No such list.
" % list_name
sys.exit(0)
def GetArchiveList(list):
archive_list = htmlformat.UnorderedList()
def ArchiveFilter(str):
if str[:7] <> 'volume_':
return 0
try:
x = eval(str[7:])
if type(x) <> types.IntType:
return 0
if x < 1:
return 0
return 1
except:
return 0
try:
dir_listing = filter(ArchiveFilter, os.listdir(list.archive_directory))
except posix.error:
return "No archives are currently available.
"
if not len(dir_listing):
return "No archives are currently available.
"
for dir in dir_listing:
link = htmlformat.Link(os.path.join(list._base_archive_url, dir),
"Volume %s" % dir[7:])
archive_list.AddItem(link)
return archive_list.Format()
replacements = list.GetStandardReplacements()
replacements[''] = GetArchiveList(list)
# Just doing print list.ParseTags(...) calls ParseTags twice???
text = list.ParseTags('archives.html', replacements)
print text