iwla

iwla Commit Details

Date:2020-12-09 13:24:29 (7 months 20 days ago)
Author:Grégory Soutadé
Branch:dev
Commit:c0e3e0a801e1c5cae2ea6fddd4508572b718d20a
Parents: f457f4e390e29db7a665355db7d5b8aaaf463f06
Message:Update code for Python3

Changes:
Mdisplay.py (7 diffs)
Miwla.py (2 diffs)
Mplugins/post_analysis/referers.py (2 diffs)

File differences

display.py
7676
7777
7878
79
79
8080
8181
82
82
8383
8484
85
85
8686
8787
88
88
8989
9090
9191
......
143143
144144
145145
146
146
147147
148148
149149
150150
151151
152152
153
153
154154
155155
156156
......
169169
170170
171171
172
172
173173
174174
175175
176176
177177
178
178
179179
180180
181181
......
255255
256256
257257
258
258
259259
260260
261261
......
267267
268268
269269
270
271
270
271
272
273
274
272275
273276
274277
......
321324
322325
323326
324
327
325328
326329
327330
......
421424
422425
423426
424
427
425428
426429
430
431
432
433
434
435
427436
428
429
437
438
430439
431440
432
441
433442
434
443
435444
436445
446
437447
438448
439449
440
450
441451
442452
443
444
453
454
445455
446456
447457
return self.title
def setTitle(self, value):
self.title = unicode(value)
self.title = value
def setCSSClass(self, cssclass):
self.cssclass = unicode(cssclass)
self.cssclass = cssclass
def setTitleCSSClass(self, cssclass):
self.title_cssclass = unicode(cssclass)
self.title_cssclass = cssclass
def setValueCSSClass(self, cssclass):
self.value_cssclass = unicode(cssclass)
self.value_cssclass = cssclass
def _buildHTML(self):
html = u'<div class="%s">' % (self.cssclass)
row >= len(self.rows) or col >= len(self.cols):
raise ValueError('Invalid indices %d,%d' % (row, col))
self.rows[row][col] = unicode(value)
self.rows[row][col] = value
def setCellCSSClass(self, row, col, value):
if row < 0 or col < 0 or\
row >= len(self.rows) or col >= len(self.cols):
raise ValueError('Invalid indices %d,%d' % (row, col))
self.rows_cssclasses[row][col] = unicode(value)
self.rows_cssclasses[row][col] = value
def getCellCSSClass(self, row, col):
if row < 0 or col < 0 or\
if row < 0 or row >= len(self.rows):
raise ValueError('Invalid indice %d' % (row))
self.rows_cssclasses[row] = [unicode(value)] * len(self.rows_cssclasses[row])
self.rows_cssclasses[row] = [value] * len(self.rows_cssclasses[row])
def setColCSSClass(self, col, value):
if col < 0 or col >= len(self.cols):
raise ValueError('Invalid indice %d' % (col))
self.cols_cssclasses[col] = unicode(value)
self.cols_cssclasses[col] = value
def setColsCSSClass(self, values):
if len(values) != len(self.cols):
super(DisplayHTMLBlockTableWithGraph, self).appendRow(row)
def appendShortTitle(self, short_title):
self.short_titles.append(unicode(short_title))
self.short_titles.append(short_title)
def setShortTitle(self, short_titles):
self.short_titles = listToStr(short_titles)
for i in range(0, self.nb_valid_rows):
row = self.raw_rows[i]
for j in range(1, len(row)):
if row[j] > self.maxes[j]:
self.maxes[j] = row[j]
try:
if row[j] > self.maxes[j]:
self.maxes[j] = row[j]
except:
continue
def _getIconFromStyle(self, style):
if style.startswith(u'iwla_page'): icon = u'vp.png'
def __init__(self, iwla, title, filename, css_path):
self.iwla = iwla
self.title = unicode(title)
self.title = title
self.filename = filename
self.blocks = []
self.css_path = listToStr(css_path)
# Global functions
#
def bytesToStr(bytes):
def bytesToStr(_bytes):
suffixes = [u'', u' kB', u' MB', u' GB', u' TB']
try:
if type(_bytes) != int:
_bytes = int(_bytes, 10)
except:
return _bytes
for i in range(0, len(suffixes)):
if bytes < 1024: break
bytes /= 1024.0
if _bytes < 1024: break
_bytes /= 1024.0
if i:
return u'%.02f%s' % (bytes, suffixes[i])
return u'%.02f%s' % (_bytes, suffixes[i])
else:
return u'%d%s' % (bytes, suffixes[i])
return u'%d%s' % (_bytes, suffixes[i])
def _toStr(v):
return v
if type(v) != unicode: return unicode(v)
else: return v
def listToStr(l): return map(lambda v : _toStr(v), l)
def listToStr(l): return l #map(lambda v : _toStr(v), l)
def generateHTMLLink(url, name=None, max_length=100, prefix=u'http'):
url = unicode(url)
if not name: name = unicode(url)
url = url
if not name: name = url
if not url.startswith(prefix): url = u'%s://%s' % (prefix, url)
return u'<a href="%s">%s</a>' % (url, name[:max_length])
iwla.py
482482
483483
484484
485
485
486486
487
487
488488
489489
490490
......
642642
643643
644644
645
646
645647
646648
647649
row = [0, nb_visits, stats['viewed_pages'], stats['viewed_hits'], stats['viewed_bandwidth'], stats['not_viewed_bandwidth']]
if nb_days:
average_row = map(lambda v: int(v/nb_days), row)
average_row = list(map(lambda v: int(v/nb_days), row))
else:
average_row = map(lambda v: 0, row)
average_row = list(map(lambda v: 0, row))
average_row[0] = self._('Average')
average_row[4] = bytesToStr(average_row[4])
self._callPlugins(conf.POST_HOOK_DIRECTORY)
if args.display_only:
if not 'stats' in self.meta_infos.keys():
self.meta_infos['stats'] = {}
self._generateDisplay()
return
plugins/post_analysis/referers.py
1919
2020
2121
22
22
2323
2424
2525
......
113113
114114
115115
116
116
117117
118118
119119
#
import re
import urllib
import urllib.parse
from iwla import IWLA
from iplugin import IPlugin
if groups:
key_phrase = groups.groupdict()['key_phrase']
try:
key_phrase = urllib.unquote_plus(key_phrase).decode('utf8')
key_phrase = urllib.parse.unquote_plus(key_phrase)
except Exception as e:
print(e)
continue

Archive Download the corresponding diff file

Branches

Tags