iwla

iwla Commit Details

Date:2014-11-22 19:23:56 (6 years 8 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:38c041126d1b1604ec47b64c5591b92a69e121b6
Parents: db84036d8a7c66e8a66bffceffdf1785670b1c96
Message:Plugins management seems ok

Changes:
Mdefault_conf.py (1 diff)
Miwla.py (4 diffs)
Mplugins/display/top_visitors.py (1 diff)

File differences

default_conf.py
22
33
44
5
5
66
7
8
9
7
8
9
1010
1111
1212
DB_ROOT = './output/'
DISPLAY_ROOT = './output/'
HOOKS_ROOT = './plugins/'
HOOKS_ROOT = 'plugins'
PRE_HOOK_DIRECTORY = HOOKS_ROOT + 'pre_analysis/'
POST_HOOK_DIRECTORY = HOOKS_ROOT + 'post_analysis/'
DISPLAY_HOOK_DIRECTORY = HOOKS_ROOT + 'display/'
PRE_HOOK_DIRECTORY = HOOKS_ROOT + '.pre_analysis'
POST_HOOK_DIRECTORY = HOOKS_ROOT + '.post_analysis'
DISPLAY_HOOK_DIRECTORY = HOOKS_ROOT + '.display'
META_PATH = DB_ROOT + 'meta.db'
DB_FILENAME = 'iwla.db'
iwla.py
11
22
3
34
45
56
......
78
89
910
11
1012
1113
1214
......
4143
4244
4345
44
46
47
4548
46
47
49
50
51
52
53
54
55
4856
4957
5058
......
122130
123131
124132
125
133
126134
127135
128136
#!/usr/bin/env python
import sys
import os
import re
import time
import imp
import pickle
import gzip
import importlib
from display import *
ret = True
for root in self.plugins.keys():
for plugin_name in self.plugins[root]:
p = root + '/' + plugin_name
#p = root + '/' + plugin_name
p = root + '.' + plugin_name
try:
fp, pathname, description = imp.find_module(plugin_name, [root])
self.cache_plugins[p] = imp.load_module(p, fp, pathname, description)
# fp, pathname, description = imp.find_module(plugin_name, [root])
# self.cache_plugins[p] = imp.load_module(p, fp, pathname, description)
#p = 'plugins.display.top_visitors'
#sys.path.append(root)
#self.cache_plugins[p] = importlib.import_module(plugin_name, root)
#sys.path.remove(root)
self.cache_plugins[p] = importlib.import_module(p)
mod = self.cache_plugins[p]
infos = mod.get_plugins_infos()
if infos['class'] != IWLA.ANALYSIS_CLASS or \
print '==> Call plugins (%s)' % root
for p in self.plugins[root]:
print '\t%s' % (p)
mod = self.cache_plugins[root + '/' + p]
mod = self.cache_plugins[root + '.' + p]
mod.hook(*args)
def isPage(self, request):
plugins/display/top_visitors.py
1717
1818
1919
20
21
22
23
24
2025
2126
2227
def hook(iwla):
stats = iwla.getMonthStats()
if not 'top_visitors' in stats.keys():
print 'Top visitors post analysis plugin not installed'
return
index = iwla.getDisplayIndex()
table = DisplayHTMLBlockTable('Top visitors', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen'])
for super_hit in stats['top_visitors']:

Archive Download the corresponding diff file

Branches

Tags