-
Notifications
You must be signed in to change notification settings - Fork 1
/
spausk.py
executable file
·73 lines (56 loc) · 2.08 KB
/
spausk.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#! /usr/bin/env python
################################################################################
# RelMon: a tool for automatic Release Comparison
# https://twiki.cern.ch/twiki/bin/view/CMSPublic/RelMon
#
# $Author: dpiparo $
# $Date: 2011/07/14 11:11:03 $
# $Revision: 1.5 $
#
#
# Danilo Piparo CERN - [email protected]
#
# Transform all html files into a directory into .htmlgz files and add the
# .htaccess file to tell Apache to serve the new compressed data.
# Moves also the pickles away.
#
################################################################################
htaccess_content="""
RewriteEngine on
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule (.*)\.html$ $1\.htmlgz [L]
RewriteRule (.*)\.png$ $1\.pnggz [L]
AddType "text/html;charset=UTF-8" .htmlgz
AddEncoding gzip .htmlgz
AddType "image/png" .pnggz
AddEncoding gzip .pnggz
DirectoryIndex RelMonSummary.htmlgz
"""
from os.path import exists
from os import system
from sys import argv,exit
argc=len(argv)
if argc!=2:
print "Usage: %prog directoryname"
exit(-1)
directory = argv[1]
while directory[-1]=="/": directory= directory[:-1]
if not exists(directory):
print "Directory %s does not exist: aborting!"%directory
exit(-1)
#print "Moving pkls away..."
#pkl_dir="%s_pkls" %directory
#system("mkdir %s" %pkl_dir)
#system("mv %s/*pkl %s" %(directory,pkl_dir))
#print "All pkls moved in directory %s" %pkl_dir
print "Backupping directory %s" %directory
system("cp -r %s %s_gz"%(directory,directory)) # i know, it should be better..
print "Backupped!"
print "Gzipping content of %s" %directory
system("time gzip -r -S gz %s_gz"%directory) # i know, it should be better..
print "Content of %s zipped!" %directory
#print "Adding .htaccess file..."
#htaccess=open("%s/.htaccess"%directory,"w")
#htaccess.write(htaccess_content)
#htaccess.close()
#print "Apache .htaccess file successfully added!"