Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 htaccess_content="""
00020 RewriteEngine on
00021
00022 RewriteCond %{HTTP:Accept-Encoding} gzip
00023 RewriteRule (.*)\.html$ $1\.htmlgz [L]
00024 RewriteRule (.*)\.png$ $1\.pnggz [L]
00025
00026 AddType "text/html;charset=UTF-8" .htmlgz
00027 AddEncoding gzip .htmlgz
00028
00029 AddType "image/png" .pnggz
00030 AddEncoding gzip .pnggz
00031
00032 DirectoryIndex RelMonSummary.htmlgz
00033
00034 """
00035
00036
00037 from os.path import exists
00038 from os import system
00039 from sys import argv,exit
00040
00041 argc=len(argv)
00042
00043 if argc!=2:
00044 print "Usage: %prog directoryname"
00045 exit(-1)
00046
00047 directory = argv[1]
00048
00049 while directory[-1]=="/": directory= directory[:-1]
00050
00051 if not exists(directory):
00052 print "Directory %s does not exist: aborting!"%directory
00053 exit(-1)
00054
00055 print "Moving pkls away..."
00056 pkl_dir="%s_pkls" %directory
00057 system("mkdir %s" %pkl_dir)
00058 system("mv %s/*pkl %s" %(directory,pkl_dir))
00059 print "All pkls moved in directory %s" %pkl_dir
00060
00061 print "Backupping directory %s" %directory
00062 system("cp -r %s %s_back"%(directory,directory))
00063 print "Backupped!"
00064
00065 print "Gzipping content of %s" %directory
00066 system("time gzip -r -S gz %s"%directory)
00067 print "Content of %s zipped!" %directory
00068
00069 print "Adding .htaccess file..."
00070 htaccess=open("%s/.htaccess"%directory,"w")
00071 htaccess.write(htaccess_content)
00072 htaccess.close()
00073 print "Apache .htaccess file successfully added!"