Add try/catch in browsers display plugin in case of an icon doesn't exists)
This commit is contained in:
parent
588b3179d5
commit
00ad08a201
|
@ -82,12 +82,15 @@ class IWLADisplayBrowsers(IPlugin):
|
||||||
new_list = self.max_browsers and browsers[:self.max_browsers] or browsers
|
new_list = self.max_browsers and browsers[:self.max_browsers] or browsers
|
||||||
for (browser, entrance) in new_list:
|
for (browser, entrance) in new_list:
|
||||||
if browser != 'unknown':
|
if browser != 'unknown':
|
||||||
|
try:
|
||||||
icon = '<img src="/%s/browser/%s.png"/>' % (self.icon_path, awstats_data.browsers_icons[self.icon_names[browser]])
|
icon = '<img src="/%s/browser/%s.png"/>' % (self.icon_path, awstats_data.browsers_icons[self.icon_names[browser]])
|
||||||
|
except:
|
||||||
|
icon = '<img src="/%s/browser/unknown.png"/>' % (self.icon_path)
|
||||||
else:
|
else:
|
||||||
icon = '<img src="/%s/browser/unknown.png"/>' % (self.icon_path)
|
icon = '<img src="/%s/browser/unknown.png"/>' % (self.icon_path)
|
||||||
browser = 'Unknown'
|
browser = 'Unknown'
|
||||||
table.appendRow([icon, browser, entrance])
|
table.appendRow([icon, browser, entrance])
|
||||||
total_browsers[1] += entrance
|
total_browsers[2] += entrance
|
||||||
if self.max_browsers:
|
if self.max_browsers:
|
||||||
others = 0
|
others = 0
|
||||||
for (browser, entrance) in browsers[self.max_browsers:]:
|
for (browser, entrance) in browsers[self.max_browsers:]:
|
||||||
|
@ -111,14 +114,18 @@ class IWLADisplayBrowsers(IPlugin):
|
||||||
table.setColsCSSClass(['', '', 'iwla_hit'])
|
table.setColsCSSClass(['', '', 'iwla_hit'])
|
||||||
for (browser, entrance) in browsers[:10]:
|
for (browser, entrance) in browsers[:10]:
|
||||||
if browser != 'unknown':
|
if browser != 'unknown':
|
||||||
|
try:
|
||||||
icon = '<img src="/%s/browser/%s.png"/>' % (self.icon_path, awstats_data.browsers_icons[self.icon_names[browser]])
|
icon = '<img src="/%s/browser/%s.png"/>' % (self.icon_path, awstats_data.browsers_icons[self.icon_names[browser]])
|
||||||
|
except:
|
||||||
|
icon = '<img src="/%s/browser/unknown.png"/>' % (self.icon_path)
|
||||||
else:
|
else:
|
||||||
icon = '<img src="/%s/browser/unknown.png"/>' % (self.icon_path)
|
icon = '<img src="/%s/browser/unknown.png"/>' % (self.icon_path)
|
||||||
browser = 'Unknown'
|
browser = 'Unknown'
|
||||||
table.appendRow([icon, browser, entrance])
|
table.appendRow([icon, browser, entrance])
|
||||||
total_browsers[1] -= entrance
|
total_browsers[2] -= entrance
|
||||||
if total_browsers[1]:
|
if total_browsers[2]:
|
||||||
total_browsers[0] = self.iwla._(u'Others')
|
total_browsers[0] = u''
|
||||||
|
total_browsers[1] = self.iwla._(u'Others')
|
||||||
table.appendRow(total_browsers)
|
table.appendRow(total_browsers)
|
||||||
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
|
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
|
||||||
index.appendBlock(table)
|
index.appendBlock(table)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user