iwla

iwla Commit Details

Date:2014-12-15 21:28:25 (6 years 7 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:4f4e4648438819f3316d7ab4cae9a6589c22f752
Parents: e327a1ff3579bcb2c378d7ef58b4f495fcdc2fe5
Message:Add file compression

Changes:
MTODO (1 diff)
Mconf.py (1 diff)
Mdefault_conf.py (1 diff)
Miwla.py (3 diffs)

File differences

TODO
44
55
66
7
87
98
10
9
10
doc enhancement
Limit hits/pages/downloads by rate
Automatic tests
quiet mode
Add Licence
Free memory as soon as possible
gzip output files
gzip output files
different debug output levels
conf.py
2424
2525
2626
27
28
# Because it's too long to build HTML when there is too much entries
max_hits_displayed = 100
max_downloads_displayed = 100
compress_output_files = ['html', 'css', 'js']
default_conf.py
4848
4949
5050
51
52
53
icon_path = '%s/%s' % (os.path.basename(resources_path[0]), 'icon')
# CSS path (you can add yours)
css_path = ['%s/%s/%s' % (os.path.basename(resources_path[0]), 'css', 'iwla.css')]
# Extensions to compress in gzip during display build
compress_output_files = []
iwla.py
3131
3232
3333
34
3435
3536
3637
......
4041
4142
4243
43
44
4445
4546
4647
......
441442
442443
443444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
444465
445466
446467
447468
469
448470
471
449472
450473
451474
# Conf values needed :
# analyzed_filename
# domain_name
# compress_output_files*
#
# Output files :
# DB_ROOT/meta.db
#
# Statistics creation :
#
# meta =>
# meta :
# last_time
# start_analysis_time
# stats =>
self.display.addPage(page)
def _compressFile(self, build_time, root, filename):
path = os.path.join(root, filename)
gz_path = path + '.gz'
#print 'Compress %s => %s' % (path, gz_path)
if not os.path.exists(gz_path) or\
os.stat(filename).st_mtime > build_time:
with open(path, 'rb') as f_in:
with gzip.open(gz_path, 'wb') as f_out:
f_out.write(f_in.read())
def _compressFiles(self, build_time, root):
if not conf.compress_output_files: return
print root
for rootdir, subdirs, files in os.walk(root, followlinks=True):
for f in files:
for ext in conf.compress_output_files:
if f.endswith(ext):
self._compressFile(build_time, rootdir, f)
break
def _generateDisplay(self):
self._generateDisplayDaysStats()
self._callPlugins(conf.DISPLAY_HOOK_DIRECTORY)
self._generateDisplayWholeMonthStats()
build_time = time.localtime()
self.display.build(conf.DISPLAY_ROOT)
self._compressFiles(build_time, conf.DISPLAY_ROOT)
def _createEmptyStats(self):
stats = {}

Archive Download the corresponding diff file

Branches

Tags