Utilities
RelMon
scripts
dir2webdir.py
Go to the documentation of this file.
1
#! /usr/bin/env python3
2
15
16
from
__future__
import
print_function
17
htaccess_content=
"""
18
RewriteEngine on
19
20
RewriteCond %{HTTP:Accept-Encoding} gzip
21
RewriteRule (.*)\.html$ $1\.htmlgz [L]
22
RewriteRule (.*)\.png$ $1\.pnggz [L]
23
24
AddType "text/html;charset=UTF-8" .htmlgz
25
AddEncoding gzip .htmlgz
26
27
AddType "image/png" .pnggz
28
AddEncoding gzip .pnggz
29
30
DirectoryIndex RelMonSummary.htmlgz
31
32
"""
33
34
35
from
os.path
import
exists
36
from
os
import
system
37
from
sys
import
argv,exit
38
39
argc=len(argv)
40
41
if
argc!=2:
42
print
(
"Usage: %prog directoryname"
)
43
exit
(-1)
44
45
directory = argv[1]
46
47
while
directory[-1]==
"/"
: directory= directory[:-1]
48
49
if
not
exists(directory):
50
print
(
"Directory %s does not exist: aborting!"
%directory)
51
exit
(-1)
52
53
print
(
"Moving pkls away..."
)
54
pkl_dir=
"%s_pkls"
%directory
55
system(
"mkdir %s"
%pkl_dir)
56
system(
"mv %s/*pkl %s"
%(directory,pkl_dir))
57
print
(
"All pkls moved in directory %s"
%pkl_dir)
58
59
print
(
"Backupping directory %s"
%directory)
60
system(
"cp -r %s %s_back"
%(directory,directory))
# i know, it should be better..
61
print
(
"Backupped!"
)
62
63
print
(
"Gzipping content of %s"
%directory)
64
system(
"time gzip -r -S gz %s"
%directory)
# i know, it should be better..
65
print
(
"Content of %s zipped!"
%directory)
66
67
print
(
"Adding .htaccess file..."
)
68
htaccess=open(
"%s/.htaccess"
%directory,
"w"
)
69
htaccess.write(htaccess_content)
70
htaccess.close()
71
print
(
"Apache .htaccess file successfully added!"
)
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition:
Utilities.cc:46
beamvalidation.exit
def exit(msg="")
Definition:
beamvalidation.py:52
Generated for CMSSW Reference Manual by
1.8.16