iwla

iwla Commit Details

Date:2015-02-18 20:56:03 (6 years 5 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:f5b0c35bad6ad6f32808d2bdfbea85ce66fd1471
Parents: cfbd35d818bd495076ce11b416dd84bbb2396803
Message:Add a star for merged feeds parsers

Changes:
Mplugins/display/feeds.py (2 diffs)
Mplugins/post_analysis/feeds.py (4 diffs)

File differences

plugins/display/feeds.py
2121
2222
2323
24
25
24
2625
2726
2827
......
8180
8281
8382
83
84
8485
8586
8687
8788
8889
89
90
91
9092
9193
9294
from iwla import IWLA
from iplugin import IPlugin
from display import *
import awstats_data
from plugins.post_analysis.feeds import IWLAPostAnalysisFeeds
"""
Display hook
if display_visitor_ip and\
super_hit.get('dns_name_replaced', False):
address = '%s [%s]' % (address, super_hit['remote_ip'])
if super_hit['feed_parser'] == IWLAPostAnalysisFeeds.MERGED_FEED_PARSER:
address += '*'
if super_hit['robot']:
table.appendRow([address, super_hit['not_viewed_pages'], super_hit['not_viewed_hits']])
else:
table.appendRow([address, super_hit['viewed_pages'], super_hit['viewed_hits']])
page.appendBlock(table)
note = DisplayHTMLRaw(self.iwla, ('<small>*%s</small>' % (self.iwla._('Merged feeds parsers'))))
page.appendBlock(note)
display.addPage(page)
# Found in index
plugins/post_analysis/feeds.py
3535
3636
3737
38
3839
3940
4041
......
5152
5253
5354
55
56
57
58
5459
5560
5661
62
5763
5864
5965
66
6067
6168
6269
......
7077
7178
7279
80
81
7382
7483
75
84
7685
7786
7887
......
8190
8291
8392
84
93
94
8595
8696
8797
8898
89
99
90100
91101
92102
93
103
94104
95105
96106
97
107
98108
99
109
110
111
112
Conf values needed :
feeds
merge_one_hit_only_feeds_parsers*
Output files :
None
"""
class IWLAPostAnalysisFeeds(IPlugin):
NOT_A_FEED_PARSER = 0
FEED_PARSER = 1
MERGED_FEED_PARSER = 2
def __init__(self, iwla):
super(IWLAPostAnalysisFeeds, self).__init__(iwla)
self.API_VERSION = 1
self.conf_requires = ['feeds']
def load(self):
feeds = self.iwla.getConfValue('feeds', None)
self.merge_one_hit_only_feeds_parsers = self.iwla.getConfValue('merge_one_hit_only_feeds_parsers', True)
if feeds is None: return False
if isFeedParser and (hit['viewed_hits'] + hit['not_viewed_hits']) == 1:
user_agent = hit['requests'][0]['http_user_agent'].lower()
if one_hit_only.get(user_agent, None) is None:
# Merged
isFeedParser = self.MERGED_FEED_PARSER
one_hit_only[user_agent] = (hit)
else:
isFeedParser = False
isFeedParser = self.NOT_A_FEED_PARSER
hit['feed_parser'] = isFeedParser
def hook(self):
for hit in hits.values():
isFeedParser = hit.get('feed_parser', None)
if isFeedParser == True:
if isFeedParser == self.FEED_PARSER and\
self.merge_one_hit_only_feeds_parsers:
self.mergeOneHitOnlyFeedsParsers(one_hit_only, hit)
if not isFeedParser is None: continue
isFeedParser = False
isFeedParser = self.NOT_A_FEED_PARSER
uri = hit['requests'][0]['extract_request']['extract_uri'].lower()
for regexp in self.feeds_re:
if regexp.match(uri):
isFeedParser = True
isFeedParser = self.FEED_PARSER
# Robot that views pages -> bot
if hit['robot']:
if hit['viewed_pages']:
isFeedParser = False
isFeedParser = self.NOT_A_FEED_PARSER
break
self.mergeOneHitOnlyFeedsParsers(isFeedParser, one_hit_only, hit)
if self.merge_one_hit_only_feeds_parsers:
self.mergeOneHitOnlyFeedsParsers(isFeedParser, one_hit_only, hit)
else:
hit['feed_parser'] = isFeedParser

Archive Download the corresponding diff file

Branches

Tags