#!/usr/bin/python
import cgi_config
import sys;
import os, os.path, glob
import re
import cgi;
import cgitb; cgitb.enable()
import shutil
import ac_config
from td_config import config,read_config
import td_tools
import td_doctree
import td_generate
import td_tools
import td_archive
import td_debug
td_debug.in_cgi = True
form = cgi.FieldStorage()
print "Content-type: text/html; charset=UTF-8"
print
print ""
print "
"
print ''
print ""
print ""
print ""
print '| -=[Create an archive]=- |
'
def error(msg):
print "Error
"
print msg
def create_archive(category):
zipname = category.replace('/','_') + ".zip"
doctree = td_doctree.build(config['input_path'])
td_archive.generate_category(doctree,
category,
config['archives_path'] + "/" + zipname)
print 'Archive %s ready.
' % (config['archives_url'] + "/" + zipname, zipname)
def process():
read_config(cgi_config.file)
if not form.has_key("category"):
print "Category was not provided or empty category."
return
category = form["category"].value
if len(category) == 0:
print "Empty category."
return
create_archive(category)
process()
print ""