Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
src
Utilities
RelMon
scripts
dir2webdir.py
Go to the documentation of this file.
1
#! /usr/bin/env python
2
################################################################################
3
# RelMon: a tool for automatic Release Comparison
4
# https://twiki.cern.ch/twiki/bin/view/CMSPublic/RelMon
5
#
6
# $Author: dpiparo $
7
# $Date: 2012/06/12 12:25:27 $
8
# $Revision: 1.1 $
9
#
10
#
11
# Danilo Piparo CERN - danilo.piparo@cern.ch
12
#
13
# Transform all html files into a directory into .htmlgz files and add the
14
# .htaccess file to tell Apache to serve the new compressed data.
15
# Moves also the pickles away.
16
#
17
################################################################################
18
19
htaccess_content=
"""
20
RewriteEngine on
21
22
RewriteCond %{HTTP:Accept-Encoding} gzip
23
RewriteRule (.*)\.html$ $1\.htmlgz [L]
24
RewriteRule (.*)\.png$ $1\.pnggz [L]
25
26
AddType "text/html;charset=UTF-8" .htmlgz
27
AddEncoding gzip .htmlgz
28
29
AddType "image/png" .pnggz
30
AddEncoding gzip .pnggz
31
32
DirectoryIndex RelMonSummary.htmlgz
33
34
"""
35
36
37
from
os.path
import
exists
38
from
os
import
system
39
from
sys
import
argv,exit
40
41
argc=len(argv)
42
43
if
argc!=2:
44
print
"Usage: %prog directoryname"
45
exit
(-1)
46
47
directory = argv[1]
48
49
while
directory[-1]==
"/"
: directory= directory[:-1]
50
51
if
not
exists(directory):
52
print
"Directory %s does not exist: aborting!"
%directory
53
exit
(-1)
54
55
print
"Moving pkls away..."
56
pkl_dir=
"%s_pkls"
%directory
57
system(
"mkdir %s"
%pkl_dir)
58
system(
"mv %s/*pkl %s"
%(directory,pkl_dir))
59
print
"All pkls moved in directory %s"
%pkl_dir
60
61
print
"Backupping directory %s"
%directory
62
system(
"cp -r %s %s_back"
%(directory,directory))
# i know, it should be better..
63
print
"Backupped!"
64
65
print
"Gzipping content of %s"
%directory
66
system(
"time gzip -r -S gz %s"
%directory)
# i know, it should be better..
67
print
"Content of %s zipped!"
%directory
68
69
print
"Adding .htaccess file..."
70
htaccess=open(
"%s/.htaccess"
%directory,
"w"
)
71
htaccess.write(htaccess_content)
72
htaccess.close()
73
print
"Apache .htaccess file successfully added!"
cmsRelvalreport.exit
tuple exit
Definition:
cmsRelvalreport.py:1000
Generated for CMSSW Reference Manual by
1.8.5