Plugins management seems ok
This commit is contained in:
parent
db84036d8a
commit
38c041126d
|
@ -2,11 +2,11 @@
|
|||
|
||||
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'
|
||||
|
||||
|
|
16
iwla.py
16
iwla.py
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
|
@ -7,6 +8,7 @@ import glob
|
|||
import imp
|
||||
import pickle
|
||||
import gzip
|
||||
import importlib
|
||||
|
||||
from display import *
|
||||
|
||||
|
@ -41,10 +43,16 @@ class IWLA(object):
|
|||
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 \
|
||||
|
@ -122,7 +130,7 @@ class IWLA(object):
|
|||
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):
|
||||
|
|
|
@ -17,6 +17,11 @@ def load():
|
|||
|
||||
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']:
|
||||
|
|
Loading…
Reference in New Issue
Block a user